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 ---- 05/30/14 04:30 PM

Post by JHPJHP »

Updated:
- updated cv_functions.pbi
-- added a CompilerIf statement to the IncludeFile locations to work with the new release of PureBasic

- added 3 examples
-- cv_enhance_detail.pb: enhance the details of an image
-- cv_smooth_edge.pb: smooth the edges of an image using a recursive filter
-- cv_stylization.pb: stylize an image by applying various filters
- added 6 images

Examples are based on the C++ blending scripts mentioned in a previous post.

Note: As with cv_pencil_sketch.pb, there are parameters for each of the new examples that will increase / decrease the intended effect.

NB*: Update also includes bug fixes and improvements to various examples including a fix to cv_transparent.pb for single channel images.

Cheers!
Last edited by JHPJHP on Sat May 31, 2014 1:45 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.
AAT
Enthusiast
Enthusiast
Posts: 259
Joined: Sun Jun 15, 2008 3:13 am
Location: Russia

Re: PureBasic Interface to OpenCV ---- 05/30/14 04:30 PM

Post by AAT »

Hi, JHPJHP!
Thank you for your new examples!
updated the include files to work with the new release of PureBasic
There is nothing new in version 5.30 that would change prototypes of OpenCV functions.
Do you think it's necessary?

P.S. My congratulations to all, who read this topic: this is the 2^8 reply :D
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV ---- 05/30/14 04:30 PM

Post by JHPJHP »

Hi AAT,

You're welcome - I'm glad you like the new examples.

Prototypes were not changed, but the following bit of code was added:

Code: Select all

CompilerIf #PB_Compiler_Version < 530
  IncludeFile "includes/cv_constants.pbi"
  IncludeFile "includes/cv_structures.pbi"
  IncludeFile "includes/cv_macros.pbi"
  IncludePath "binaries"
CompilerElse
  IncludeFile "cv_constants.pbi"
  IncludeFile "cv_structures.pbi"
  IncludeFile "cv_macros.pbi"
  IncludePath "../binaries"
CompilerEndIf
Last edited by JHPJHP on Mon Jun 09, 2014 1:11 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.
User avatar
bbanelli
Enthusiast
Enthusiast
Posts: 544
Joined: Tue May 28, 2013 10:51 pm
Location: Europe
Contact:

Re: PureBasic Interface to OpenCV ---- 05/30/14 04:30 PM

Post by bbanelli »

Greetings,

first of all, thank you so much for sharing this great code for PB!

All of your previous examples worked well for me, however, after downloading newest, I don't seem to be able to get it running.

I have followed instructions from readme.txt but it didn't help. PB 5.22 and W7 x64.

http://tinypic.com/r/2nu60b5/8

I have tried fiddling with paths but it didn't help. What am I doing wrong?

TIA!
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV ---- 05/31/14 03:15 PM

Post by JHPJHP »

Hi bbanelli,

You're welcome.

I fixed the issue reported in your previous post; I've also included some additional examples.

Enjoy.

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

Updated:
- renamed 2 examples
-- cv_smooth_edge.pb to cv_smooth_edges_1.pb
-- cv_stylization.pb to cv_stylize_1.pb
- added 4 examples
-- cv_depth_of_field.pb: using a second image as a mask to compare against an object in the original image, depth of field is simulated
-- cv_enhance_edges.pb: enhance the edges of an image using various filters
-- cv_smooth_edges_2.pb: smooth the edges of an image using a normalized convolution filter
-- cv_stylize_2.pb: stylize an image by applying various filters
- updated 1 example
-- cv_norm.pb: using a default image, the absolute difference is calculated against a directory of images, returning the closest match
- added 4 images

Examples are based on the C++ blending scripts mentioned in a previous post, with the exception of cv_norm.pb.

Note:
- cv_enhance_edges.pb has an extra "SPACEBAR" option needed to view the full effect.
- cv_norm.pb
-- added an option to flip through all the images
-- added a smoothing filter (increased accuracy)

NB*: This completes the conversion of code created by Siddharth Kherada to PureBasic.
Last edited by JHPJHP on Mon Jun 09, 2014 1:14 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.
User avatar
bbanelli
Enthusiast
Enthusiast
Posts: 544
Joined: Tue May 28, 2013 10:51 pm
Location: Europe
Contact:

Re: PureBasic Interface to OpenCV ---- 05/31/14 03:15 PM

Post by bbanelli »

JHPJHP wrote:Hi bbanelli,

You're welcome.

I fixed the issue caused by the change I mage to IncludeFile - thank you for pointing it out; I've also included some additional examples.
Works like a charm now, thank you once again!!!
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV ---- 05/31/14 03:15 PM

Post by JHPJHP »

Various updates and bug fixes not worth documenting have been applied to the "PureBasic Interface to OpenCV" package, including an additional 4 images.

Some of the updated examples:
- cv_depth_of_field.pb
- cv_enhance_detail.pb
- cv_enhance_edges.pb
- cv_norm.pb
- cv_pencil_sketch.pb
- cv_smooth_edges_1.pb
- cv_smooth_edges_2.pb
- cv_stylize_1.pb
- cv_stylize_2.pb
- cv_template.pb
-- 4 images added

NB*: Thank you PureBasic team for an amazing product, that keeps getting better.

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 ---- 05/31/14 03:15 PM

Post by JHPJHP »

Updated:
- added 1 example
-- cv_pseudo_colors.pb: augment an image with a set of predetermined colors
- added 4 images

Based on script found here.

NB*: I'm pretty much finished with my OpenCV experiment, but from time to time I may add an example, taking a break from the workload.

Image Image
Last edited by JHPJHP on Mon Jun 16, 2014 7:23 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
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Re: PureBasic Interface to OpenCV ---- 06/15/14 09:15 PM

Post by Rings »

thx JHPJHP and all other contributors for this really cool stuff.
Very very usefull!!!
SPAMINATOR NR.1
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV ---- 06/15/14 09:15 PM

Post by JHPJHP »

Hi Rings,

You're welcome, and thank you for the kudos.

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

Added a small update to the example: cv_pseudo_colors.pb.
- added additional color map images

Note: Instead of using multiple color map images, a single image with multiple gradients could be used instead, by modifying the following lines of code:
- change the 1's to the X-coordinates of the new gradient colors, possibly applied every time the Spacebar is pressed

Code: Select all

cvGet2D(@scalar1, *B, color, 1)
cvGet2D(@scalar2, *G, color, 1)
cvGet2D(@scalar3, *R, color, 1)

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 ---- 07/06/14 08:00 AM

Post by JHPJHP »

Updated:
- added 1 example (jointly contributed by Shardik)
-- pb_cam_gl_cube.pb: using OpenGL and textures, the webcam interface is displayed onto the surfaces of a rotating cube

Because of the great new addition of OpenGL by the PureBasic team, and all the related code examples contributed by so many others, I was able to add this new example.

The majority of the OpenGL script came from this post: http://www.purebasic.fr/english/viewtop ... 00#p446600.
~by Shardik.

NB*: Compatible with PureBasic 5.30 and above.

Image
Last edited by JHPJHP on Sun Jul 06, 2014 4:09 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 ---- 07/06/14 08:00 AM

Post by Mythros »

OMG! Is there a way you can add audio to it? Like even if the audio didn't come from OpenCV but like another library or something?

Thanks alot, JHP! :)
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV ---- 07/06/14 08:00 AM

Post by JHPJHP »

Hi Mythros,

I'm sorry, but like I've mentioned previously, audio is not something I plan on adding to the package.

As it stands this is a completed project, not to say that I won't add a new example from time to time, but I'm content that the "PureBasic Interface to OpenCV" is respectively covered.

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

I've optimized the example: pb_cam_gl_cube.pb... nothing to do with improving Shardik code, I just rearranged how some of the functions were laid-out, resulting in a smoother effect.

Cheers!

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 ---- 07/06/14 08:00 AM

Post by applePi »

thanks JHPJHP for merging OpenCV with OpenGL ,it seems very good, this is really unexpected achievement. i have thought of this a few weeks ago but hesitated to ask.
i have downloaded the latest OpenCV.zip. running pb_cam_gl_cube.pb but there is no output screen.
my system purebasic 5.30 beta 6 windows xp/32bit. i can run all opengl examples. and opencv examples except the "pb_cam_gl_cube.pb"
thanks for all your efforts
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV ---- 07/06/14 08:00 AM

Post by JHPJHP »

Hi applePi,

Are you using PureBasic 5.30, the example pb_cam_gl_cube.pb utilizes it's latest features, also a webcam is required.
- no output (error information) usually indicates a problem connecting to the webcam; I didn't trap for that

NB*: I've only had the opportunity to test the example on Windows 7.

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

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