Page 14 of 60

Re: PureBasic Interface to OpenCV ---- 03/26/14 10:45 PM

Posted: Fri Mar 28, 2014 1:14 am
by AAT
Hi JHPJHP!

You have at least one (it's me :) ) who want to see more examples. Please add its to the package.
You le_stitching.pb example is very impressive! I will take photos over the weekend to experiment more.

Good luck!

Re: PureBasic Interface to OpenCV ---- 03/27/14 12:40 AM

Posted: Fri Mar 28, 2014 6:12 am
by JHPJHP
Hi AAT,

I spent the time and updated the new example to conform to the existing standards - I hope you have some fun with it.

Thanks for responding, your appreciation makes all the effort worth while.

----------------------------------------

Updated:
- renamed 1 example
-- le_stitching.pb to le_stitching_1.pb
- added 1 example
-- le_stitching_2.pb: stitches images together; based on the SIFT (Scale Invariant Feature Transform) algorithm
- added 14 images

Also includes some minor updates to other examples - not worth documenting.

Unlike the first stitching example which demonstrated each stage of the SIFT process, this example takes a group of images (2, 3, 4 and 5 exclusively) and stitches them together directly.
- when the variance between multiple image perspectives is high, there is a greater degree of distortion
- another thing to be aware of is the order of images, which need to be loaded from right to left

5 image stitch: I cut a panoramic image into 5 overlapping images, the resulting stitched images are near prefect due to their identical perspectives
3 image stitch: you should see in the third image (right side), that the size of the double doors is distorted compared with the original image
- with three or more images, and depending on their perspective angles, the resulting output can be a radically distorted image
-- fixing this should be fairly simple with a few changes to the code

Some setting to be aware of (Feature Detection and Description):
- #PARAMS_EXTENDED
-- 0 means that the basic descriptors (64 elements each) shall be computed
-- 1 means that the extended descriptors (128 elements each) shall be computed
- #PARAMS_THRESHOLD
-- threshold for the keypoint detector
--- a good default value could be from 300 to 500, depending from the image contrast

Re: PureBasic Interface to OpenCV ---- 03/28/14 12:40 AM

Posted: Fri Mar 28, 2014 1:25 pm
by yrreti
Some setting to be aware of (Feature Detection and Description):
Just a minor error on the link that causes a 404
feature_detection.html)
just remove the extra ) at the end of the link and its ok.
Thanks for the link.

Re: PureBasic Interface to OpenCV ---- 03/28/14 12:40 AM

Posted: Fri Mar 28, 2014 1:35 pm
by JHPJHP
Hi yrreti,

The link is now fixed... I wondered if anyone was reading the posts. :o

Thank you.

Re: PureBasic Interface to OpenCV ---- 03/28/14 12:40 AM

Posted: Fri Mar 28, 2014 1:42 pm
by Thunder93
I'm reading the posts. Good job you have been doing here.

Re: PureBasic Interface to OpenCV ---- 03/28/14 12:40 AM

Posted: Fri Mar 28, 2014 1:49 pm
by JHPJHP
Hi again Thunder93, :)

Thanks for the kudos, your acknowledgement is very much appreciated.

Cheers!

Re: PureBasic Interface to OpenCV ---- 03/30/14 10:00 AM

Posted: Sun Mar 30, 2014 9:45 pm
by JHPJHP
Updated:
- updated 2 examples
-- le_stitching_1.pb: stitch together 2 images in stages; based on the SIFT (Scale Invariant Feature Transform) algorithm
-- le_stitching_2.pb: stitch together 2, 3, 4, or 5 images; based on the SIFT (Scale Invariant Feature Transform) algorithm
- deleted 4 images
- replaced 7 images

Added a Procedure to better frame the stitched image, including minor improvements and some bug fixes.

Also includes some minor updates to other examples - not worth documenting.

-------------------------------------------------

Updated:
- added 1 example
-- cv_retro.pb: retro-style photo effect done by adding noise to the luminance channel and reducing intensity of the chroma channels
- added 2 images

Original Code: image.cpp found in the current version of OpenCV.

NB*: Helpful information: Transform CvArr, CvMat and IplImage.

Re: PureBasic Interface to OpenCV ---- 03/30/14 10:00 AM

Posted: Wed Apr 02, 2014 8:50 am
by Morty
Thanks again for your work ... it's amazing to see what you did and how it extends PureBasic. Keep on :D

Re: PureBasic Interface to OpenCV ---- 04/04/14 03:00 PM

Posted: Fri Apr 04, 2014 8:17 pm
by JHPJHP
Hi Morty,

Thank you for your kind words - I really appreciate the acknowledgement.

----------------------------------------

Updated:
- added 1 example
-- cv_calcbackproject.pb: calculating the back projection of a histogram, frequent density values are displayed as bright pixels

Re: PureBasic Interface to OpenCV ---- 04/06/14 01:35 AM

Posted: Sun Apr 06, 2014 7:04 am
by JHPJHP
Updated:
- updated Functions
- added 2 examples
-- cv_cam_pixelate.pb: pixelate a webcam stream by averaging NxN block regions, and applying the color values to grid squares
-- cv_imagedots.pb: creates an image by averaging 10x10 block regions, and applying the color values to a dot matrix

cv_cam_pixelate.pb:
Image

Re: PureBasic Interface to OpenCV ---- 04/06/14 01:35 AM

Posted: Sun Apr 06, 2014 11:26 am
by marc_256
hi JHPJHP,

first at all, thanks again for all your nice work,
second, do you ever sleep ? :wink: :mrgreen:

marc,

Re: PureBasic Interface to OpenCV ---- 04/06/14 11:40 PM

Posted: Mon Apr 07, 2014 4:48 am
by JHPJHP
Hi marc_256,

You're welcome, and thank you for the acknowledgement. As for your question on whether I sleep or not...

Sleep, those little slices of death; Oh how I loathe them.
~Edgar Allan Poe

----------------------------------

Updated:
- added 3 examples
-- cv_logpolar.pb: remaps an image to log-polar space
-- le_delaunay_1.pb: manual construction of delaunay triangulation
-- le_delaunay_2.pb: random construction of delaunay triangulation
- changed the naming convention from 1a, 1b, etc. to 1, 2, etc.

le_delaunay_*.pb: based on script found here.

Re: PureBasic Interface to OpenCV ---- 04/10/14 09:40 PM

Posted: Fri Apr 11, 2014 2:52 am
by JHPJHP
Updated:
- added Constants, Structures, Functions
- added 2 examples
-- cv_sepia.pb: convert a color image to sepia
-- le_mov_bgstatmodel.pb: using a Gaussian mixture-based background/foreground detection algorithm, foreground objects are highlighted by comparing the current frame with a static frame
- added 1 movie file: walking.avi

NB*: New Functions are from the legacy DLL - all others have been declared.

Even though the functions used in le_mov_bgstatmodel.pb are from the legacy DLL, there are numerous object-detection possibilities; I may play around with this some more.

-----------------------------------------------------

Updated:
- renamed 1 example
-- le_mov_bgstatmodel.pb to le_mov_bgstatmodel_1.pb
- added 1 example
-- le_mov_bgstatmodel_2.pb: using a background/foreground detection algorithm, foreground objects are highlighted/removed by comparing the current frame with a static frame

I found a bug in the previous example, while fixing that problem I decided to add an additional example using the BGStatModel functions.

Cheers!

Re: PureBasic Interface to OpenCV ---- 04/10/14 09:40 PM

Posted: Fri Apr 11, 2014 2:14 pm
by AAT
Hi, JHPJHP

Thanks for your greate new examples!
The example le_mov_bgstatmodel_1.pb is very interesting! I saw it but I didn't knew how to translate it into PureBasic. Great!

------------
I had a need to keep the images processed with opencv in a database (in BLOB). The code with saving the image into a temporary file works too slow, so i found the solution how to make conversion in the memory. For example:

Code: Select all

*image.IplImage = cvQueryFrame(*capture)     ; getting  image from the webcam
...
If *image
  *mat.CvMat = cvEncodeImage(".jpg", *image, 0)
  Result = CatchImage(1, *mat\ptr)        
  *imgbuf = EncodeImage(1, #PB_ImagePlugin_JPEG);
  bufsize = MemorySize(*imgbuf)
  
  If OpenDatabase(0, DatabaseFile, "", "")                   
    SetDatabaseBlob(0, 0, *imgbuf, bufsize)
    Result = CheckDatabaseUpdate(0, "INSERT INTO ...")
    If Result <> 0
      ...
    Else
      ...      
    EndIf  
  EndIf
  ...  
EndIf
P.S. The code works fine but jpeg compression level is too high. I don't know how to regulate the compression level. :(

Good luck!

Re: PureBasic Interface to OpenCV ---- 04/11/14 02:45 PM

Posted: Fri Apr 11, 2014 8:35 pm
by JHPJHP
Hi AAT,

You're welcome, I'm glad you're enjoying the examples.

Conversion in memory is definitely the way to go, I wrote a Comic Book reader using the same functions because of the speed improvement over file access.
jpeg compression level is too high. I don't know how to regulate the compression level
It's done the same way as with the cvSaveImage Function, the new example should give you a clearer picture (ignore the pun) :) .

---------------------------------------------

Updated:
- updated 1 Function
- added Procedures
- added 1 example
-- cv_cam_pbdatabase.pb: captures and saves webcam frames to a database, displaying a thumbnail version of the image loaded from the database

I usually like to work with PostgreSQL, but that obviously wouldn't work in this case, so the database I'm using is SQLite - I'm impressed with the size and speed.

Creating a database entry: ImportImage(*image, name.s, extension.s = ".jpg")
- first parameter is an OpenCV image
- second parameter is part of the database entry name (string)
-- the rest of the name is automatically generated: dd_mm_yyyy_hh_mm_ss_fff (milliseconds used for fast captures)
-- this should allow for organizing/sorting the database
- third parameter is optional
- returns the database entry name (string)

Retrieving a database entry: GetDBImage(dbName.s)
- parameter is database entry name (string)
- returns an OpenCV image

Note:
- after pressing the SPACEBAR if the thumbnail image shows/changes, then the database update/retrieval is working properly.

NB*: Image compression is static, but can be changed from the Procedure: ImportImage().