PureBasic Interface to OpenCV

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

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi AAT,

I'm glad you liked the example, but I thought you would have gotten a bigger kick out of the image mask added to [ cv_cam_haardetect_face.pb ] and [ cv_haardetect_face.pb ].

Captcha Recognition: I was thinking along those lines myself; so far for every solution that comes to mind I in-turn find a reason it won't work, but who knows :?:

I wish I thought of "Fish plays Streetfighter" :lol:

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

Updated the example: cv_LBP.pb
- added additional alternate methods, but removed key (Spacebar) access to them

The alternate methods return the same results, so it seemed redundant to show them, even with different filters. But I kept the methods in the example because they may provide help with accessing image data under different circumstances.

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 was not paying attention and missed that you added the masks in your examples.
Yesterday I read the material on your link, found an example with masks on C and ran it. It was fun. :D
I was going to translate it to PB, opened your suitable example and found that it's already done. You were the first! :lol:

Good luck!
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: PureBasic Interface to OpenCV

Post by dige »

JHPJHP wrote:Updated
cv_haardetect_face.pb: (default image file)
1. Using the Spacebar switch the HaarCascade file: Blue outline
2. Using the Trackbar adjust Scale to: 0
3. Press the "S" key once to toggle scale-factor: On
The face detection works pretty nice. Does OpenCV also provide possibilities to recognize a face again? I'd like it to use to automatically attach names to faces.
Many thanks again JHPJHP, for the continuous development!
"Daddy, I'll run faster, then it is not so far..."
AAT
Enthusiast
Enthusiast
Posts: 259
Joined: Sun Jun 15, 2008 3:13 am
Location: Russia

Re: PureBasic Interface to OpenCV

Post by AAT »

dige wrote: Does OpenCV also provide possibilities to recognize a face again? I'd like it to use to automatically attach names to faces.
Hi, dige!
I think, it's impossible with OpenCV only.
Haarcascade detects face as an object with a set of basic features but it does not recognize the face.
This is well illustrated in example cv_haardetect_face.pb.

----------------
Update: http://docs.opencv.org/modules/contrib/ ... ecognition
I haven't seen working example yet.

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

PureBasic Interface to OpenCV

Post by JHPJHP »

Hi AAT,

I think I saw the same "C" example, but I believe my solution is a little cleaner; I did borrow :wink: the images / masks though.

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

Hi dige,

There are a couple examples that can do what you ask, but their strict in their comparison methods.

Take a look at: cv_template.pb
- compares a template against overlapped image regions; matching one face against many faces
- if you continue to press the Spacebar it will attempt to find other faces matching the template
- press the Enter key to load another face to match
- this can easily be adapted for the webcam

Also take a look at: cv_norm.pb
- using a default image, the absolute difference is calculated against a directory of images, returning the closest match
- press the Spacebar to start the search, and skip to the next closest match

... but AAT is correct with the link he posted, providing a more robust solution.
- the new examples mentioned below address these concerns

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

I've been working on two HaarTraining examples, but to use them is not as simple as point-and-click.

For those of you interested in "Object / Face Recognition" not to be confused with "Face Detection" (already included in the current package), the new examples accomplish this. But creating the files can take days without the assurance of success; so far I've only achieved marginal accuracy...

... Working on the main part of the code took a couple days, but an additional week was spent modifying and testing the script to improve results.

Creating a HaarCascade classifier: If anyone is interested in testing the code I'm willing to provide an update now, otherwise I'll hold off on adding the new examples to the package while my tests continue.

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: 2250
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Updated:
- added Constants, 1 Macro, Structures
- added 4 examples
-- cv_cam_haar_training_1.pb: Haar-Training in stages for single face recognition (new version)
-- cv_cam_haar_training_2.pb: Haar-Training in stages for single face recognition (old version)
-- cv_bezier_curve.pb: Bézier Curve: A parametric curve frequently used in computer graphics and related fields
-- cv_goodfeatures.pb: determines strong corners on an image, marked by circles
- added 4 executable files
-- opencv_createsamples.exe, opencv_traincascade.exe, opencv_haartraining.exe, opencv_performance.exe
- added 1 trained file
-- neg_train.txt
- added 2 trained folders
-- \binaries\trained\negatives
-- \binaries\trained\positives
- added 1 reference file
-- haarcascade.txt

cv_bezier_curve.pb: Based on script found here.

cv_goodfeatures.pb: This example was created because of a question previously asked concerning corner detection, and the webcam example didn't provide the answer I was looking for.

Update also includes small enhancements to various examples.

I won't clutter this post with instructions for running [ cv_cam_haar_training_1.pb ] and [ cv_cam_haar_training_2.pb ], but a general understanding of the process would help chances for returning accurate results; the added reference file [ haarcascade.txt ] is a good start.

NB*: Most of the new additions to the package can be ignored as they are dependencies to the classifier examples.
Last edited by JHPJHP on Sat Jul 11, 2015 9:49 pm, 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.
Mythros
Enthusiast
Enthusiast
Posts: 306
Joined: Mon Aug 19, 2013 3:28 pm

Re: PureBasic Interface to OpenCV

Post by Mythros »

Hi, JHP! Can you add "control mouse with finger via any webcam" examples? I'm taking a thorough interest in OpenCV again & would like to test this out.

Thanks alot, JHP!

Mythros
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: PureBasic Interface to OpenCV

Post by dige »

Hi JHPJHP, cant find the download link at the first paghe anymore. Does everything now included in the OpenCV distribution?
"Daddy, I'll run faster, then it is not so far..."
AAT
Enthusiast
Enthusiast
Posts: 259
Joined: Sun Jun 15, 2008 3:13 am
Location: Russia

Re: PureBasic Interface to OpenCV

Post by AAT »

Hi.
Perhaps, JHPJHP wants to upgrade his pack?
Little John
Addict
Addict
Posts: 4777
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: PureBasic Interface to OpenCV

Post by Little John »

Just want to say that I'd like to download the current version as well. :-)
User avatar
JHPJHP
Addict
Addict
Posts: 2250
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi - sorry for the delay,

I was away for a few days and didn't think anyone would notice... I put the following off until I returned:

I'm having some issues with the PureBasic website, just waiting to hear back from the Administrator; currently I can't update the first post. Possibly because I replaced the link with the following special characters: P̶u̶r̶e̶B̶a̶s̶i̶c̶ ̶I̶n̶t̶e̶r̶f̶a̶c̶e̶ ̶t̶o̶ ̶O̶p̶e̶n̶C̶V while I completed some maintenance.

Thank you,
Last edited by JHPJHP on Thu Sep 04, 2014 7:33 am, 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.
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: PureBasic Interface to OpenCV

Post by applePi »

Hi JHPJHP
just a few suggestion:
1- if for some reason the first page are corrupted and can't accept URL, i suggest to put the download link inside the Code tab, just an experiment:
Image
2- if it can't be solved, the link can be added to the last post
3- or make a new thread with the same title part-2, and refer to the old thread
4- i was worrying like the others you have stopped the project so thanks for the feedback.
User avatar
JHPJHP
Addict
Addict
Posts: 2250
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi applePi,

All good suggestions, I'll give them a try in the next couple days if the problem persists, or can't be fixed.

Thank you for your concern and feedback.

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

Update: Fred fixed the error. A link to the latest update is available in the first post.

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

Updated:
- added 3 examples
-- cv_cam_foreground.pb: displays a threshold foreground view using filters to return the difference between frames, from the webcam interface
-- cv_cam_convexitydefects.pb: calculates the contour areas, finding the convex hull of point sets to convexity defects, displayed on the webcam interface
-- cv_fractal_3.pb: Fractal Art: Created by calculating fractal objects represented as images
- updated 4 examples
-- cv_cam_warpperspective.pb
-- cv_inpaint.pb
-- cv_warpaffine.pb
-- cv_warpperspective_1.pb

cv_fractal_3.pb: Based on script found here.

There are a lot more updated examples then are listed, but the four mentioned above demonstrate some of the improvements.

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

Hi Mythros,

Take a look at the new example: cv_cam_convexitydefects.pb - this should provide a start to your request. Another example that may be better suited for the task is: cv_cam_track_color.pb.

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

Hi dige & Little John,

Please enjoy the latest version of the package.

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

Hi AAT,

I did take a look into the new version of OpenCV (v3.0). As it's still in its Alpha build I'm going to hold off on an update, but it does look promising. Instead of multiple DLLs they are now combined into a single file: opencv_world300.dll. Currently there is no legacy DLL, but I'm hoping that will change with later releases. The new HAAR Classifiers were created for the C++ functions, but we can always use the ones from the current package. I'm sure there are more changes to come.
Last edited by JHPJHP on Mon Sep 08, 2014 8:00 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.
Little John
Addict
Addict
Posts: 4777
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: PureBasic Interface to OpenCV

Post by Little John »

Hi JHPJHP!

Image

... for the quick fix, and for all your work on this project, which is very useful and might open up undreamt-of possibilities for me.
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 seen the 3.0alpha version openCv too, but i think, that it's too early to upgrade your interface. Perhaps after 3.1 version :)

Good luck!
Locked