PureBasic Interface to OpenCV
Re: PureBasic Interface to OpenCV
Hi AAT,
Thank you for the additional information.
That's expected behaviour as VFW is not only unreliable with newer operating systems, but the latest hardware/firmware as well.
------------------------------------------------
I spent that last couple of days setting up a test environment, and building new binaries from the 2.4.11 and 3.0 versions of OpenCV...
Downloaded and Installed:
- Microsoft Visual Studio Community 2013
- CMake 3.2.3
- Windows SDK 8.1 (not using)
-- switched to Visual Studio 2013 SDK
- OpenCV 2.4.11, 3.0 Gold
Reference Sites:
- http://docs.opencv.org/3.0-beta/doc/tut ... stall.html
- http://docs.opencv.org/doc/tutorials/in ... pencv.html
- https://rangadabarera.wordpress.com/ope ... al-studio/
Tested Configurations:
- OpenCV 3.0
-- no modification to sources (webcam not working)
-- added: WITH_VIDEOINPUT (webcam not working)
-- added: WINDOWS_SDK_PATH (DirectShow requirement / included in the 2.4.11 SLN / webcam not working)
-- options matching 2.4.11 (webcam not working)
- OpenCV 2.4.11
-- no modification to sources (webcam working)
This leads me to believe that the problem is outside the scope of just adding / removing options, but still related to the availability and configuration of DirectShow.
- https://fossies.org/diffs/opencv/2.4.11_vs_3.0.0/
-- see this link, and search the page for: Capturing video from camera via DirectShow
NB*: Rebuilding the OpenCV 3.0 binaries to match the options in OpenCV 2.4.11, the file size (opencv_world300.dll) was reduced from 27 MB to 12 MB.
- disabled: SSE3, WITH_DIRECTX, etc.
Thank you for the additional information.
That's expected behaviour as VFW is not only unreliable with newer operating systems, but the latest hardware/firmware as well.
------------------------------------------------
I spent that last couple of days setting up a test environment, and building new binaries from the 2.4.11 and 3.0 versions of OpenCV...
Downloaded and Installed:
- Microsoft Visual Studio Community 2013
- CMake 3.2.3
- Windows SDK 8.1 (not using)
-- switched to Visual Studio 2013 SDK
- OpenCV 2.4.11, 3.0 Gold
Reference Sites:
- http://docs.opencv.org/3.0-beta/doc/tut ... stall.html
- http://docs.opencv.org/doc/tutorials/in ... pencv.html
- https://rangadabarera.wordpress.com/ope ... al-studio/
Tested Configurations:
- OpenCV 3.0
-- no modification to sources (webcam not working)
-- added: WITH_VIDEOINPUT (webcam not working)
-- added: WINDOWS_SDK_PATH (DirectShow requirement / included in the 2.4.11 SLN / webcam not working)
-- options matching 2.4.11 (webcam not working)
- OpenCV 2.4.11
-- no modification to sources (webcam working)
This leads me to believe that the problem is outside the scope of just adding / removing options, but still related to the availability and configuration of DirectShow.
- https://fossies.org/diffs/opencv/2.4.11_vs_3.0.0/
-- see this link, and search the page for: Capturing video from camera via DirectShow
NB*: Rebuilding the OpenCV 3.0 binaries to match the options in OpenCV 2.4.11, the file size (opencv_world300.dll) was reduced from 27 MB to 12 MB.
- disabled: SSE3, WITH_DIRECTX, etc.
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,
I think that time to use OpenCV3 didn't come yet.
Looks like old code is removed but new one isn't written.JHPJHP wrote: -- see this link, and search the page for: Capturing video from camera via DirectShow

I think that time to use OpenCV3 didn't come yet.
Re: PureBasic Interface to OpenCV
I applaud all of the work JHPJHP has put into OpenCV for PB, but I wonder where it is all headed? What can you do with a webcam and OpenCV besides view the output of the camera? Using another application to stream or record the webcam video doesn't seem possible because either OpenCV or the streaming/recording application locks up the webcam.
Re: PureBasic Interface to OpenCV
Hi chris319,
Included in the package are not only 30 plus unique webcam examples, but another 150 plus image and other examples using algorithms that can be applied to a webcam; this is only a fraction of what can be done.
Here are a few OpenCV webcam capabilities included in the package:
- face detection
- object and direction tracking
- text, image, and video overlays
- perspective, color, and filter transforms
See the example: cv_cam_zone_tracking.pb:
- demonstrates how easy it is to apply OpenCV's built-in functions to a real-world application
-- be sure to test the various options: turn on the alarm (a), toggle tracking (t), etc.
See this post by marc_256: http://www.purebasic.fr/english/viewtop ... 00#p439700
See this YouTube video: https://www.youtube.com/watch?v=idSvJ-RXhq0
- and additional associated videos
Cheers!
The list is endless...chris319 wrote:What can you do with a webcam and OpenCV besides view the output of the camera?
Included in the package are not only 30 plus unique webcam examples, but another 150 plus image and other examples using algorithms that can be applied to a webcam; this is only a fraction of what can be done.
Here are a few OpenCV webcam capabilities included in the package:
- face detection
- object and direction tracking
- text, image, and video overlays
- perspective, color, and filter transforms
See the example: cv_cam_zone_tracking.pb:
- demonstrates how easy it is to apply OpenCV's built-in functions to a real-world application
-- be sure to test the various options: turn on the alarm (a), toggle tracking (t), etc.
See this post by marc_256: http://www.purebasic.fr/english/viewtop ... 00#p439700
See this YouTube video: https://www.youtube.com/watch?v=idSvJ-RXhq0
- and additional associated videos
Cheers!
Last edited by JHPJHP on Thu Jun 18, 2015 7:13 pm, edited 6 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
Let me ask a more fundamental question: is it possible for other applications to use a webcam at the same time OpenCV is using a camera under PB? Let's say I want to overlay titles on a webcam output as it is being recorded by another application, say Windows Movie Maker.
Re: PureBasic Interface to OpenCV
Hi chris319,
As far as I know that's not inherent to OpenCV. I don't think it's easily done from most webcam applications, but there are third party tools:
- http://www.ivideon.com/how-do-i-use-a-w ... taneously/
NB*: I'm not sure if this allows OpenCV access to a live feed displayed in a seperate application.
As far as I know that's not inherent to OpenCV. I don't think it's easily done from most webcam applications, but there are third party tools:
- http://www.ivideon.com/how-do-i-use-a-w ... taneously/
NB*: I'm not sure if this allows OpenCV access to a live feed displayed in a seperate application.
Last edited by JHPJHP on Thu Jun 18, 2015 7:14 pm, edited 3 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
Hi,
ever heard of Kurento ?
http://www.kurento.org/docs/current/int ... d-protocol
You can create an input stream and use several outputs or you can add 'overlays' and so on.
I already controlled it via PB to read a videostream and detect QR-Codes inside.
Bernd
ever heard of Kurento ?
http://www.kurento.org/docs/current/int ... d-protocol
You can create an input stream and use several outputs or you can add 'overlays' and so on.
I already controlled it via PB to read a videostream and detect QR-Codes inside.
Bernd
Re: PureBasic Interface to OpenCV
Hi,chris319,
Webcam isn't right choice.
I think you can use IP the camera for these purpose. It can transmit multiple streams simultaneously.chris319 wrote:... is it possible for other applications to use a webcam at the same time OpenCV is using a camera under PB?...
Webcam isn't right choice.
Re: PureBasic Interface to OpenCV
Hi AAT,
As we both know OpenCV has been pulling away from their C-Interface for a couple years, moving towards C++. Currently it's not viable for PureBasic to interface the C++ class functions, but an option is to modify the source code directly, adding our own C-Interface and compiling the binaries ourselves.
Take a look at the following OpenCV function: minEnclosingTriangle (included in OpenCV 3.0 and accessible only from C++ and Python).
Depending on your perspective the following may sound very easy or very difficult:
- copied the OpenCV 3.0 c++ source file, and pasted it into the OpenCV 2.4.11 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

NB:* Applying the techniques used in the above solution may fix the webcam issue we're currently facing with OpenCV 3.0, as well as provide access to functions previously not available.
I was almost ready to agree, but...Looks like old code is removed but new one isn't written.![]()
I think that time to use OpenCV3 didn't come yet.
As we both know OpenCV has been pulling away from their C-Interface for a couple years, moving towards C++. Currently it's not viable for PureBasic to interface the C++ class functions, but an option is to modify the source code directly, adding our own C-Interface and compiling the binaries ourselves.
Take a look at the following OpenCV function: minEnclosingTriangle (included in OpenCV 3.0 and accessible only from C++ and Python).
Depending on your perspective the following may sound very easy or very difficult:
- copied the OpenCV 3.0 c++ source file, and pasted it into the OpenCV 2.4.11 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

NB:* Applying the techniques used in the above solution may fix the webcam issue we're currently facing with OpenCV 3.0, as well as provide access to functions previously not available.
Last edited by JHPJHP on Tue Mar 08, 2016 8:12 am, edited 4 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
Hi, JHPJHP,
You will be the Atlas who holds the sky.
Much time, much efforts... Whether you are ready to spend years for this work?
Perhaps, it is simpler to wait for support in PureBasic the interface to C++.
I think that it will be very difficult.JHPJHP wrote:Depending on your perspective the following may sound very easy or very difficult; it falls in between:
- copied the OpenCV 3.0 c++ scouce file, and pasted it into the OpenCV 2.4.11 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
You will be the Atlas who holds the sky.
Much time, much efforts... Whether you are ready to spend years for this work?
Perhaps, it is simpler to wait for support in PureBasic the interface to C++.
Re: PureBasic Interface to OpenCV
Hi AAT,
Did you download the new example from the previous post?
You may have misunderstood what I was trying to say, or more accurately I wasn't being clear.
My intention isn't to write and maintain a C-Interface for every C++ Function, but to show that with very little effort, compared with creating the same functionality from scratch, access to areas of OpenCV previously unavailable are now possible.
I sometimes think the scope of this project is perceived as a hindrance rather then an asset. "PureBasic Interface to OpenCV" shouldn't be taken as a whole, but broken down to suite current needs. Features offered by this project are being overlooked because using it is considered overkill, but really it's no different then what was originally offered: http://www.purebasic.fr/english/viewtop ... 12&t=48212.
Did you download the new example from the previous post?
You may have misunderstood what I was trying to say, or more accurately I wasn't being clear.
My intention isn't to write and maintain a C-Interface for every C++ Function, but to show that with very little effort, compared with creating the same functionality from scratch, access to areas of OpenCV previously unavailable are now possible.
I sometimes think the scope of this project is perceived as a hindrance rather then an asset. "PureBasic Interface to OpenCV" shouldn't be taken as a whole, but broken down to suite current needs. Features offered by this project are being overlooked because using it is considered overkill, but really it's no different then what was originally offered: http://www.purebasic.fr/english/viewtop ... 12&t=48212.
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
Yes, I didn't understand the elegance of your ideas.JHPJHP wrote:...My intention isn't to write and maintain a C-Interface for every C++ Function, but to show that with very little effort, compared with creating the same functionality from scratch, access to areas of OpenCV previously unavailable are now possible...

You are right, this task no longer looks daunting.
P.S. Yes, i downloaded and tested your example with minEnclosingXXX, it's very interest. The meaning of this example came to me just now. I'm sorry.

Re: PureBasic Interface to OpenCV
Hi AAT,
Thank you, I was hoping you would see the potential.
--------------------------------------------------------------
With the latest incite to expanding PureBasic's access to OpenCV, I'm releasing the unfinished package: "PureBasic Interface to OpenCV 3.0 Gold (32bit / 64bit)".
- included are non-working examples: /xCAMERA/, /xLEGACY/
- see the first post for download link
I've also updated the two original packages with the following changes:
- combined examples: pb_cam_effects_1.pb and pb_cam_effects_2.pb
- renamed example: pb_cam_effects_3.pb to pb_cam_effects_2.pb
- renamed example: cv_minarea.pb to cv_minarea_1.pb
- added Function: cvMinEnclosingTriangle
- added example: cv_minarea_2.pb
- created folder: binaries/original
-- replaced binaries: opencv_imgproc2411.dll, opencv_imgproc2411.lib
NB*: Update also includes improvements to various examples and Function declarations.
Thank you, I was hoping you would see the potential.
--------------------------------------------------------------
With the latest incite to expanding PureBasic's access to OpenCV, I'm releasing the unfinished package: "PureBasic Interface to OpenCV 3.0 Gold (32bit / 64bit)".
- included are non-working examples: /xCAMERA/, /xLEGACY/
- see the first post for download link
I've also updated the two original packages with the following changes:
- combined examples: pb_cam_effects_1.pb and pb_cam_effects_2.pb
- renamed example: pb_cam_effects_3.pb to pb_cam_effects_2.pb
- renamed example: cv_minarea.pb to cv_minarea_1.pb
- added Function: cvMinEnclosingTriangle
- added example: cv_minarea_2.pb
- created folder: binaries/original
-- replaced binaries: opencv_imgproc2411.dll, opencv_imgproc2411.lib
NB*: Update also includes improvements to various examples and Function declarations.
Last edited by JHPJHP on Tue Jun 23, 2015 3:13 am, edited 1 time 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
PureBasic Interface to OpenCV 3.0 Gold (32bit / 64bit)
- fixed the problems in the C++ source scripts that stopped the webcam from connecting
- compiled a new set of binaries for x86 / x64
Included legacy examples [ /xLEGACY/ ] are not currently working due to the excluded binaries from this OpenCV release.
NB*: Small improvements have also been applied to the original x86 / x64 interfaces.
- fixed the problems in the C++ source scripts that stopped the webcam from connecting
- compiled a new set of binaries for x86 / x64
Included legacy examples [ /xLEGACY/ ] are not currently working due to the excluded binaries from this OpenCV release.
NB*: Small improvements have also been applied to the original x86 / x64 interfaces.
Last edited by JHPJHP on Tue Jun 23, 2015 9:45 pm, edited 1 time 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
:thumpup:
and
:respect:
and
:respect: