PureBasic Interface to OpenCV

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi AAT,

I've added your example to all three packages; let me know if you find any problems.

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

Updated:
- added 1 example
-- cv_cam_undistort.pb (contributed by AAT)

*NB: See the previous post for a full description.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Updated:
- OpenCV v2.4.11 to v2.4.12

Fixed a few examples that stopped working when the unicode option was added.

Updated the example cv_cam_haar_training.pb to work with the new binaries.
- see the following file for instructions: references/haarcascade.txt

Rebuilt the binaries opencv_imgproc2412.dll / opencv_imgproc2412.lib to include the Function cvMinEnclosingTriangle.
- copied the OpenCV 3.1 c++ source file, and pasted it into the OpenCV 2.4.12 source folder
- modified the C++ source file to include a simple C-Interface to the C++ function
- added various header references pointing to the C-Interface function
- fixed any version problems reported when trying to compile

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Updated:
- OpenCV v3.0 to v3.1

Modified the C++ source file min_enclosing_triangle.cpp to include a simple C-Interface to the C++ function.

Modified various C++ binaries to get the webcam interface working in PureBasic.

The examples cv_cam_chessboard_2.pb and cv_cam_undistort.pb have been updated in all packages due to changes in the Function cvCalibrateCamera2.
- cv_cam_chessboard_2.pb includes text similar to cv_cam_undistort.pb (contributed by AAT)

NB*: I've noticed some speed improvements in OpenCV 3.1.
- compare the difference using the example cv_rotate_2.pb from both versions

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

Rebuilt the OpenCV 3.1 binaries (modified C/C++ script including header files) to include the following Functions:
- cvCalcGlobalOrientation, cvCalcMotionGradient, cvSegmentMotion, cvUpdateMotionHistory

Updated:
- added [ back ] 1 example
-- cv_cam_motionhistory.pb

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
AAT
Enthusiast
Enthusiast
Posts: 259
Joined: Sun Jun 15, 2008 3:13 am
Location: Russia

Re: PureBasic Interface to OpenCV

Post by AAT »

Hi, JHPJHP!
Thanks for your news! Active work and frequent package upgrade - аs at the beginning of the project. :)
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi AAT,

You're very much welcome.

I'm currently working on a new example based on the following script: Face Morph.

Updated:
- updated le_delaunay_1.pb
- added three images
- added three trained files

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

Updated:
- added 1 example
-- cv_morph_faces.pb ( demo video )
- added 1 trained file

If you're interested in a visual representation of the (trained) data see the example le_delaunay_1.pb.
- with very little modification the example can be used to create the data files
Last edited by JHPJHP on Wed May 25, 2016 7:03 pm, edited 5 times in total.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Updated:
- added 1 example
-- cv_HOG.pb

Histogram of Oriented Gradients (HOG) is used to detect objects.
- additional information: Histograms of Oriented Gradients for Human Detection
- based on script found here

NB*: There is an additional parameter (GRADIENT_SIZE) in the Procedure SetHOG that can be used to modify the results further.
Last edited by JHPJHP on Tue Mar 22, 2016 10:20 am, edited 1 time in total.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Updated:
- added 1 example
-- cv_spider_web.pb

For better results let the example run until you see the process slowing.
- there are numerous parameters that can be changed to alter the results
-- #ACCURACY, nDistance, nSpeed, #MAX_TRIES, #TESTS
- the slower the process, the finer the web, the better the detail
- based on script found here

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

Updated:
- renamed cv_spider_web.pb to cv_spider_web_2.pb
- added 2 examples
-- cv_cam_spider_web.pb
-- cv_spider_web_1.pb

cv_cam_spider_web.pb:
- press the Spacebar once to capture a frame and start drawing
- press the Spacebar a second time to stop drawing
- press the Spacebar a third time to return to the webcam
- while in Spider Web mode press the S KEY to save the image

NB*: The previous example returned a gray-scale image, the new examples return a color image.

Image

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Fix an incorrect parameter in the Procedure cvContourPerimeter, reported by AAT. With this change more accurate results are returned in the following examples:
-- cv_find_shapes.pb, cv_find_squares.pb

Thank you AAT for your support and acknowledgement throughout this project.

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

Updated:
- changed the default Open / Save locations for all examples
- fixed a memory leak in the example cv_morph_faces.pb

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
AAT
Enthusiast
Enthusiast
Posts: 259
Joined: Sun Jun 15, 2008 3:13 am
Location: Russia

Re: PureBasic Interface to OpenCV

Post by AAT »

Hi, JHPJHP!
Thanks for the kind words.

My first attempt to find a traffic speed sign on the picture: http://rghost.ru/8lzCvdZxP
Image

Have fun :)
Last edited by AAT on Fri Mar 25, 2016 2:15 pm, edited 1 time in total.
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi AAT,

That would be a great addition to the project, let me know when you have a final version ready.
- NOTE: the link in the previous post is no longer available

Cheers!

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
AAT
Enthusiast
Enthusiast
Posts: 259
Joined: Sun Jun 15, 2008 3:13 am
Location: Russia

Re: PureBasic Interface to OpenCV

Post by AAT »

Hi, JHPJHP
I have updated the link in my previous post. It will be actual within 90 days.

This script works also with the webcam http://rghost.ru/87blhFQms
It yields not really stable result and fine tuning is required.
You should set threshold levels in points "Threshold1" and "Threshold2" to obtain the results like on pictures "check1" and "check2".

Webcam shoots images from the LCD monitor
Image

Check1 image
Image

Check2 image
Image

This example is a by-product from other project. I don't think that I will have time to achieve stable work of this example :oops:

Good luck!
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi AAT,
AAT wrote:I don't think that I will have time to achieve stable work of this example
No worries, I'll still add the example to the project in the coming week, it's a good companion to cv_find_plate.pb.

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

Updated:
- deleted 1 example
-- cv_filter2d.pb
- added 5 examples
-- cv_edges.pb: Add an edge filter to an image detecting edges in all directions.
-- cv_emboss.pb: Add an emboss filter to an image giving it a 3D shadow effect.
-- cv_motion_blur.pb: Add a motion blur filter to an image blurring in only one direction.
-- cv_sharpen.pb: Add an edge filter to an image giving it a sharpened effect.
-- cv_watercolors.pb: Apply a watercolor effect to an image using a recursive bilateral filter.

I deleted the example cv_filter2d.pb because some of the filter matrices were irrelevant or incorrect.

The examples cv_edges.pb, cv_emboss.pb, cv_motion_blur.pb, and cv_sharpen.pb were based on the following tutorial: Lode's Computer Graphics Tutorial.

The example cv_watercolors.pb was based on script found here.

Embossed Image:
Image
Last edited by JHPJHP on Sun Mar 27, 2016 12:52 pm, edited 2 times in total.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Updated:
- renamed 1 example
-- cv_find_plate.pb to cv_find_license_plate.pb
- added 2 examples
-- cv_find_speed_sign.pb (contributed by AAT)
-- cv_mov_scene_detection.pb
- replaced 1 image
- added 1 movie file

cv_mov_scene_detection.pb: Based on script found here.
- detect scene changes on a movie file using similarity measurements between frames

Image

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Updated:
- renamed 1 example
-- cv_emboss.pb to cv_emboss_1.pb
- added 2 examples
-- cv_emboss_2.pb: using an extended Sobel operator an embossed effect is acheived
-- cv_gaussian_laplacian.pb: a visual representation of a Gaussian and Laplacian Pyramid

cv_emboss_2.pb:
- working with the example cv_sobel.pb I noticed that if I manipulated the image type combined with scaling, an embossed effect could be achieved

cv_gaussian_laplacian.pb:
- demonstrates how to create a Gaussian and Laplacian Pyramid: based on documentation found here
- the two arrays (GaussianPyramid / LaplacianPyramid) hold working pyramid matrices

NB*: I'm in the process of creating an example that uses the Gaussian / Laplacian Pyramid technique to blend images, similar to what was achieved with cv_poisson_blending_1.pb.

Image

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Based on advice from AAT, I returned some of the deleted examples - update reposted.

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

Updated:
- moved the folder /default/ from /binaries/ to root ../ (affecting 1 example)
-- pb_cam_preferences.pb now referencing the folder /other/
- updated 2 Procedures (affecting 5 examples)
-- cvCalcHist / cvCalcBackProject: cv_calcbackproject.pb, cv_cam_camshift.pb, cv_cam_histogram.pb, cv_histogram_1.pb, cv_histogram_2.pb
- updated 2 groups of Procedures (affecting 1 example)
-- cvGetHistValue / cvQueryHistValue: cv_cam_histogram.pb
- updated 37 examples that use the Trackbar Procedure / Function
-- CvTrackbarCallback, cvCreateTrackbar
- deleted 1 examples
-- cv_pow.pb (function used incorrectly)
- renamed 9 examples
-- cv_calculate.pb to cv_add_subtract.pb
-- cv_cam_skin_1.pb to cv_cam_skin_detection_2.pb
-- cv_cam_skin_2.pb to cv_cam_skin_detection_3.pb
-- cv_cam_skin_3.pb to cv_cam_skin_detection_4.pb
-- cv_cam_skin_4.pb to cv_cam_skin_detection_5.pb
-- cv_cam_skin_5.pb to cv_cam_skin_detection_6.pb
-- cv_cam_haar_training_1.pb to cv_cam_haardetect_train_1.pb
-- cv_cam_haar_training_2.pb to cv_cam_haardetect_train_2.pb
-- cv_cam_haar_wavelet.pb to cv_cam_haar_transform.pb
- updated 5 examples
-- cv_add_subtract.pb, cv_cam_haar_transform.pb, cv_contours_1.pb, le_stitching_1.pb, le_stitching_2.pb
- added 8 examples
-- cv_cam_skin_detection_1.pb: based on script found here
-- cv_cam_warpaffine.pb: based on script found here
-- cv_color_balance_1.pb: based on script found here
-- cv_color_balance_2.pb: based on script found here
-- cv_haar_transform.pb: based on script found here
-- cv_laplacian_blending.pb: based on script found here
-- cv_oil_painting.pb: based on script found here
-- cv_radial_blur.pb: based on script found here

cv_add_subtract.pb
- removed the multiply and divide functions (used incorrectly)
- example now saves the state between operations

cv_cam_haar_transform.pb
- AAT you were correct, the example needed fixing

le_stitching_1.pb, le_stitching_2.pb
- included an equalize intensity Procedure
- added the basic algorithm from cv_color_balance_2.pb, but could be improved by using one of the advanced algorithms in either example

cv_cam_skin_detection.pb
- provides a better solution then the other 5 skin detection examples

cv_laplacian_blending.pb
- results are similar to the example cv_poisson_blending_1.pb
- additional documentation

Image

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
Locked