PureBasic Interface to OpenCV

Developed or developing a new product in PureBasic? Tell the world about it.
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!
Your example is perfect, as always :D
NB*: Not sure if anyone noticed, but I added a toggle PIP window option to all relevant examples.
Yes, i noticed. It is often useful, the transformation is more prominent.

Good luck!
kvitaliy
Enthusiast
Enthusiast
Posts: 162
Joined: Mon May 10, 2010 4:02 pm

Re: PureBasic Interface to OpenCV

Post by kvitaliy »

It's a great job! Thank you!
User avatar
bbanelli
Enthusiast
Enthusiast
Posts: 544
Joined: Tue May 28, 2013 10:51 pm
Location: Europe
Contact:

Re: PureBasic Interface to OpenCV

Post by bbanelli »

Brilliant, as usual! :)

Do tell, though, is there any specific reason why application should not be Unicode, since I didn't notice any issues while compiling with Unicode support?

With my best,

Bruno
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/
User avatar
graph100
Enthusiast
Enthusiast
Posts: 115
Joined: Tue Aug 10, 2010 3:17 pm

Re: PureBasic Interface to OpenCV

Post by graph100 »

The example "cv_calculate.pb" has a huge memory loss :

in the OpenCV(ImageFile.s)

replace

Code: Select all

					*resize = cvCloneImage(*reset)
by

Code: Select all

          cvReleaseImage(@*resize)
					*resize = cvCloneImage(*reset)
Last edited by graph100 on Tue Aug 12, 2014 12:51 pm, edited 1 time in total.
_________________________________________________
My Website : CeriseCode (Warning : perpetual changes & not completed ;))
User avatar
JHPJHP
Addict
Addict
Posts: 2250
Joined: Sat Oct 09, 2010 3:47 am

PureBasic Interface to OpenCV

Post by JHPJHP »

Hi ATT,

Thank you for saying so, but it was your idea, and I've always said: Most programmers are a dime a dozen, but a good idea can be worth a million dollars. :wink:

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

Hi kvitaliy,

Thank you for the reply, it's very much appreciated.

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

Hi bbanelli,

Thank you for your kind words. You're right about Unicode, but I think when I started this project the version of PureBasic I was using didn't have it defaulted, so I just continued without it.
- I've included the word optional under NOTES

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

Hi graph100,

Nice catch, how did you find it with so many examples :) Thank you for pointing it out.

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

Updated:
- updated the example cv_calculate.pb with the fix pointed out by graph100
- updated the example cv_overlay_2.pb
-- added the option to choose an image for overlay
-- added the option to choose a color for overlay

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

Additional fixes to cv_overlay_2.pb:
- cvAddWeighted (transparency) excluded when adding an image
- image mask added for better picture quality and color results
Last edited by JHPJHP on Tue Aug 26, 2014 2:37 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.
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 1 example
-- cv_cam_haar_wavelet.pb: builds a direct and inverse Haar Wavelet transform, applied to the webcam interface

Original source can be found here.

This was a good example because it allowed me to figure out some additional "C" equivalent workarounds to their "C++" counterparts.

Shrinkage applied to the inverse filter doesn't seem to produce a noticeable result. If anyone can see a problem with the code or receives differing results between HARD, SOFT, and GARROTE, please post your findings.

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: 4775
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: PureBasic Interface to OpenCV

Post by Little John »

Hi JHPJHP,

thank you very much again for your great ongoing work on this project!
I also can't see a difference here between HARD, SOFT, and GARROTE.
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 haven't skills in wavelets, but after small portion of googling i think that example isn't correct to see difference between soft, hard and garrote thresholding.
This thresholds is used to filter the noise when you restore compressed image. The source image have to be in bmp format.
This is mine (layman's :) ) opinion.

Update:

I see these pictures from my webcam. Is it right?
What means the white rectangle in the left top corner?

Image

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

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi Little John,

Thank you for your reply and for confirming the example results; I'm glad there is still some interest in this project.

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

Hi AAT,

Concerning skill in wavelets, you and me both, my knowledge consists of just what I've read this past week. But I did contact Andrey Smorodov the originator of the code (another smart Russian), and he sent me some additional information including the following comment.

"... shouldn't be very much differences in these filters, they are all shrink weak coefficients but in slightly different manner ..."

I now believe my conversion was correct all along. I've updated the example with some minor changes, but the results remained the same. If you look very closely for distorted pixels in the darker areas, varying sections, while modifying SHRINKAGE_TYPE you should notice some subtle differences.

NB*: If anyone can find a problem after comparing my conversion with Andrey Smorodov's original code, please post your finding.

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!

Yes, the updated example made the difference between thresholding viewable for now.
Good luck!
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,

Thank you again for taking a second look, I appreciate the backup.

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

Updated [ cv_cam_haardetect_face.pb ] and [ cv_haardetect_face.pb ].
- added the ability to more easily switch between the various HaarCascade files
- added 2 Trackbars
-- adjust scale factor
-- set minimum neighbors

Around the start of this project these were a couple examples that garnered some interest, so I decided to add the above features to more easily test the output.

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

Updated:
- added 1 example
-- cv_DCT.pb: performs a discrete Cosine transform of a 1D array, first displaying its power spectrum then incrementally reducing noise

Based on script found here.
The DCT is frequently used in lossy data compression applications, such as the JPEG image format. The property of the DCT that makes it quite suitable for compression is its high degree of “spectral compaction;” at a qualitative level, a signal's DCT representation tends to have more of its energy concentrated in a small number of coefficients when compared to other transforms like the DFT. This is desirable for a compression algorithm; if you can approximately represent the original (time- or spatial-domain) signal using a relatively small set of DCT coefficients, then you can reduce your data storage requirement by only storing the DCT outputs that contain significant amounts of energy.
--------------------------------------------

Updated:
- added 2 examples
-- cv_cam_DCT.pb: performs a discrete Cosine transform of a 1D array, displaying its power spectrum from the webcam interface
-- cv_cam_DFT.pb: performs a discrete Fourier transform of a 1D floating-point array, displaying its power spectrum from the webcam Interface

Based on script found in the same location as the above post.

There was also a small update to cv_DCT.pb removing some superfluous script, pointed out by AAT.

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

Updated [ cv_cam_pixelate.pb ] and [ cv_image_dots.pb ] to better fit the frame.
Last edited by JHPJHP on Tue Aug 19, 2014 1:41 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: 2250
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Updated:
- added 3 examples
-- cv_encode_decode.pb: encode / decode a 4 channel image where the black areas have been converted to transparency
-- cv_mask_black.pb: create an image mask by replacing any non-black pixels with white
-- cv_mask_color.pb: create an image mask by replacing any pixel colors that fall within the selected range with black, and any other pixels with white

This started off as a maintenance release, but as I worked through the examples and with remnants of sample scripts I had laying around, I decided to mish-mash together 3 additional examples.

NB*: Numerous patches have been applied to various examples for better stability.

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

PureBasic Interface to OpenCV

Post by JHPJHP »

Updated
- added 1 example
-- cv_CAPTCHA.pb: CAPTCHA: Completely Automated Public Turing test to tell Computers and Humans Apart
- updated 2 examples: [ cv_cam_haardetect_face.pb ] and [ cv_haardetect_face.pb ]
-- added the ability to overlay various masks
--- added 4 images
-- added an option to further refine detection: scale-factor

cv_CAPTCHA.pb: Based on script found here.

cv_cam_haardetect_face.pb: Masks react differently then the detection-outline.
- if detection is lost the mask will remain at the last location until a face is detected, while the outline will be removed

NB*: scale-factor is "On" by default.

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

NB*: Using the above settings I was only missing 6 faces.

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

Found a small error in the CAPTCHA example - now corrected.

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

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Updated:
- added 1 example
-- cv_LBP.pb: Local Binary Pattern: An efficient texture operator thresholding the neighborhood of each pixel

Example was put together from various web sources.

Local Binary Pattern can be used for various applications such as face description, having the potential to improve detection performance considerably on some datasets; read more.

NB*: I've mentioned this before, but I think it's worth repeating: this example as well as numerous others don't require OpenCV in order to demonstrate their function. The formulas are derived from concepts that can be applied strictly using PureBasic.

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!

Nice CAPTCHA, Thanks!
What do you think about captcha recognition with OpenCV? :)

I have seen good example of OpenCV (i think so): Fish plays Streetfighter http://www.youtube.com/watch?v=NHrRksz-XLI
Add some code to cv_cam_zone_tracking.pb and... voila :D

Good luck!
Locked