PureBasic Interface to OpenCV
Re: PureBasic Interface to OpenCV ---- 07/06/14 08:00 AM
sorry JHPJHP you are right, i haven't noticed the webcam , i will try it with the webcam.
i use pb 5.30 beta 6, your program does not issue any errors, it just close, it needs the webcam which i will try on another computer
thanks
i use pb 5.30 beta 6, your program does not issue any errors, it just close, it needs the webcam which i will try on another computer
thanks
Re: PureBasic Interface to OpenCV ---- 07/06/14 08:00 AM
after connecting a webCam I have tried it on windows 7 32bit and it works like Charm.
tried it on windows xp/32 bit on the same system. it works but showing the following screen

there is something rotating behind the red circles (can't show here). but when i click "X" to close the program the cube with the scene are displayed correctly but for a second before closing
regards
tried it on windows xp/32 bit on the same system. it works but showing the following screen

there is something rotating behind the red circles (can't show here). but when i click "X" to close the program the cube with the scene are displayed correctly but for a second before closing
regards
Re: PureBasic Interface to OpenCV ---- 07/06/14 08:00 AM
Hi, JHPJHP!
Thanks a lot!
Updated
-------------------------
Hi, applePi
Don't understand yet, but if you change code to
you will see the cube.
Thanks a lot!
Updated
-------------------------
Hi, applePi
Don't understand yet, but if you change code to
Code: Select all
If OpenWindow(0, 0, 0, 640, 480, #CV_WINDOW_NAME, #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
opencv = LoadImage_(GetModuleHandle_(0), @"icons/opencv.ico", #IMAGE_ICON, 35, 32, #LR_LOADFROMFILE)
SendMessage_(WindowID(0), #WM_SETICON, 0, opencv)
; SetParent_(window_handle, WindowID(0))
ToolTip(window_handle, #CV_DESCRIPTION)
FrameWidth = cvGetCaptureProperty(*capture, #CV_CAP_PROP_FRAME_WIDTH)
Re: PureBasic Interface to OpenCV ---- 07/06/14 08:00 AM
thanks AAT , yes it works now with windows xp. so it is only commenting line
SetParent_(window_handle, WindowID(0))
thank you
SetParent_(window_handle, WindowID(0))
thank you
Re: PureBasic Interface to OpenCV ---- 07/06/14 08:00 AM
Hi applePi,
Thank you for testing the example on Windows XP, and posting the problem.
-----------------------------------
Hi AAT,
Thank you for working out the problem when running the example on Windows XP, as usual you help is appreciated. And you're welcome, I'm glad you liked the example.
-----------------------------------
The package has been updated to include the fix mentioned above, as well as script added to the webcam examples to report if one cannot be found; it will not report if a webcam is in use.
Thank you for testing the example on Windows XP, and posting the problem.
-----------------------------------
Hi AAT,
Thank you for working out the problem when running the example on Windows XP, as usual you help is appreciated. And you're welcome, I'm glad you liked the example.
-----------------------------------
The package has been updated to include the fix mentioned above, as well as script added to the webcam examples to report if one cannot be found; it will not report if a webcam is in use.
If you're not investing in yourself, you're falling behind.
My PureBasic Stuff ➤ FREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
PureBasic Interface to OpenCV ---- 07/10/14 07:50 PM
Updated
- renamed 2 examples
-- cv_cam_pb_database.pb to cv_pb_cam_database.pb
-- pb_cam_gl_cube.pb to pb_gl_cam_cube.pb
- added 1 example
-- pb_gl_photo_cube.pb: using OpenGL and textures, multiple images are displayed onto the surfaces of a rotating cube
I wanted to add an OpenGL example that didn't require a webcam, so I decided to do one with multiple textures / images.
Enjoy.
- renamed 2 examples
-- cv_cam_pb_database.pb to cv_pb_cam_database.pb
-- pb_cam_gl_cube.pb to pb_gl_cam_cube.pb
- added 1 example
-- pb_gl_photo_cube.pb: using OpenGL and textures, multiple images are displayed onto the surfaces of a rotating cube
I wanted to add an OpenGL example that didn't require a webcam, so I decided to do one with multiple textures / images.
Enjoy.
Last edited by JHPJHP on Sun Jul 20, 2014 9:29 pm, edited 5 times in total.
If you're not investing in yourself, you're falling behind.
My PureBasic Stuff ➤ FREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
Re: PureBasic Interface to OpenCV ---- 07/10/14 01:30 AM
Hi applePi,
Thank you for the heads-up, but I realized my mistake shortly after uploading the new package, and had already applied a patch; you must've been the first person in the download queue.
I've opted to include the following line of code for the OpenGL examples, as opposed to removing the SetParent function; without it tooltips do not work, which are now only sacrificed when running the examples in Windows XP.
---------------------------------
Updated
- added 1 example
-- pb_gl_cam_invert.pb: using OpenGL and textures, the webcam interface is displayed onto the front and inverted onto the back of a revolving rectangle
Ok I'll admit it, now I'm just playing.
---------------------------------
Added a small update to the example: pb_gl_cam_invert.pb - improving performance.
Thank you for the heads-up, but I realized my mistake shortly after uploading the new package, and had already applied a patch; you must've been the first person in the download queue.

I've opted to include the following line of code for the OpenGL examples, as opposed to removing the SetParent function; without it tooltips do not work, which are now only sacrificed when running the examples in Windows XP.
Code: Select all
If OSVersion() > #PB_OS_Windows_XP : SetParent_(window_handle, WindowID(0)) : EndIf
Updated
- added 1 example
-- pb_gl_cam_invert.pb: using OpenGL and textures, the webcam interface is displayed onto the front and inverted onto the back of a revolving rectangle
Ok I'll admit it, now I'm just playing.

---------------------------------
Added a small update to the example: pb_gl_cam_invert.pb - improving performance.
If you're not investing in yourself, you're falling behind.
My PureBasic Stuff ➤ FREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
Re: PureBasic Interface to OpenCV
Updated:
- added 2 examples
-- cv_dithering_1.pb: implementation of the Floyd-Steinberg dithering algorithm applied to a gray-scale image
-- cv_dithering_2.pb: implementation of the Floyd-Steinberg dithering algorithm applied to a color image
References:
http://en.wikipedia.org/wiki/Floyd%E2%8 ... _dithering
http://raine.tistory.com/81
Cheers!
- added 2 examples
-- cv_dithering_1.pb: implementation of the Floyd-Steinberg dithering algorithm applied to a gray-scale image
-- cv_dithering_2.pb: implementation of the Floyd-Steinberg dithering algorithm applied to a color image
References:
http://en.wikipedia.org/wiki/Floyd%E2%8 ... _dithering
http://raine.tistory.com/81
Cheers!
Last edited by JHPJHP on Thu Jul 24, 2014 1:01 am, edited 2 times in total.
If you're not investing in yourself, you're falling behind.
My PureBasic Stuff ➤ FREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
Re: PureBasic Interface to OpenCV
AAT,
I ran the program (using Lena.jpg) and cannot see any obvious distortion in the areas you mention.
Perhaps a graphics card issue?
Here's an expanded view of the area... https://www.dropbox.com/s/5prrcmo9nqadwyv/crop2.jpg
HTH
I ran the program (using Lena.jpg) and cannot see any obvious distortion in the areas you mention.
Perhaps a graphics card issue?
Here's an expanded view of the area... https://www.dropbox.com/s/5prrcmo9nqadwyv/crop2.jpg
HTH
- It was too lonely at the top.
System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
Re: PureBasic Interface to OpenCV
Hi, blueb
Sometimes there are seams, sometimes not.
Please, try with others pictures http://rghost.ru/57052847
I will test this example in other PC with Windows 7 tomorrow (for now i use Windows XP).
By
Don't think there is a problem with the video card.blueb wrote:Perhaps a graphics card issue?
Sometimes there are seams, sometimes not.
Please, try with others pictures http://rghost.ru/57052847
I will test this example in other PC with Windows 7 tomorrow (for now i use Windows XP).
By
Re: PureBasic Interface to OpenCV
Hi AAT, blueb,
Thank you for looking at the examples.
I just tested the examples on Windows XP, but didn't see any distortion.
-----------------------------------------------------------
Hi AAT,
I think I've figured it out. I believe the problem has to do with the window size/refresh, and it only affects the display. Run the example, then open a large image (e.g. building.jpg), close the program then run it again. The lena.jpg image should display with a grid like pattern. Save the image to your desktop and open it with any image editor - it should show without any distortion.
-----------------------------------------------------------
The "fix" was simple, changed the parameter #CV_WINDOW_NORMAL to #CV_WINDOW_AUTOSIZE.
- because it had such a drastic effect on these and other examples... I've updated all the examples to this setting
Updated the example: cv_dithering_1.pb.
- modified for a second time: adjusted the algorithm for better results
Cheers!
Thank you for looking at the examples.
I just tested the examples on Windows XP, but didn't see any distortion.
-----------------------------------------------------------
Hi AAT,
I think I've figured it out. I believe the problem has to do with the window size/refresh, and it only affects the display. Run the example, then open a large image (e.g. building.jpg), close the program then run it again. The lena.jpg image should display with a grid like pattern. Save the image to your desktop and open it with any image editor - it should show without any distortion.
-----------------------------------------------------------
The "fix" was simple, changed the parameter #CV_WINDOW_NORMAL to #CV_WINDOW_AUTOSIZE.
- because it had such a drastic effect on these and other examples... I've updated all the examples to this setting
Updated the example: cv_dithering_1.pb.
- modified for a second time: adjusted the algorithm for better results
Cheers!
If you're not investing in yourself, you're falling behind.
My PureBasic Stuff ➤ FREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
Re: PureBasic Interface to OpenCV
Hi, JHPJHP!
You are right.
When you open new picture first time, the window size is slightly different of the right values http://rghost.ru/57065541/image.png
I don't know why.
Ifor
repeat twice, the window will be right size.
Also, it's possible to add one line to codebut I like your way more than my.
Good luck!
You are right.
When you open new picture first time, the window size is slightly different of the right values http://rghost.ru/57065541/image.png
I don't know why.
If
Code: Select all
cvResizeWindow(#CV_WINDOW_NAME, iWidth, iHeight)
Code: Select all
cvResizeWindow(#CV_WINDOW_NAME, *image\width, *image\height)
Also, it's possible to add one line to code
Code: Select all
If *dither
cvResizeWindow(#CV_WINDOW_NAME, *dither\width, *dither\height) ; <----------- to set properly window size
cvShowImage(#CV_WINDOW_NAME, *dither)
.....

Good luck!
Re: PureBasic Interface to OpenCV
Hi AAT,
Thanks again for taking the time to look at the examples.
----------------------
Updated the example [ cv_inpaint.pb ] with a small enhancement.
- added the ability to apply multiple inpaint methods to the loaded image
- methods are color coded
-- BLUE: Navier-Stokes
-- GREEN: [Telea04]
-- RED: Navier-Stokes & [Telea04]
NB*: Apply the current repair (spacebar) before changing the method.
Thanks again for taking the time to look at the examples.
----------------------
Updated the example [ cv_inpaint.pb ] with a small enhancement.
- added the ability to apply multiple inpaint methods to the loaded image
- methods are color coded
-- BLUE: Navier-Stokes
-- GREEN: [Telea04]
-- RED: Navier-Stokes & [Telea04]
NB*: Apply the current repair (spacebar) before changing the method.
If you're not investing in yourself, you're falling behind.
My PureBasic Stuff ➤ FREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.