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

Post by JHPJHP »

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.

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,
JHPJHP wrote: -- see this link, and search the page for: Capturing video from camera via DirectShow
Looks like old code is removed but new one isn't written. :(
I think that time to use OpenCV3 didn't come yet.
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Re: PureBasic Interface to OpenCV

Post by chris319 »

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.
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi chris319,
chris319 wrote:What can you do with a webcam and OpenCV besides view the output of the camera?
The list is endless...

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 StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Re: PureBasic Interface to OpenCV

Post by chris319 »

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.
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

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.
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 StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
infratec
Always Here
Always Here
Posts: 7583
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: PureBasic Interface to OpenCV

Post by infratec »

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
AAT
Enthusiast
Enthusiast
Posts: 259
Joined: Sun Jun 15, 2008 3:13 am
Location: Russia

Re: PureBasic Interface to OpenCV

Post by AAT »

Hi,chris319,
chris319 wrote:... is it possible for other applications to use a webcam at the same time OpenCV is using a camera under PB?...
I think you can use IP the camera for these purpose. It can transmit multiple streams simultaneously.
Webcam isn't right choice.
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

Hi AAT,
Looks like old code is removed but new one isn't written. :(
I think that time to use OpenCV3 didn't come yet.
I was almost ready to agree, but...

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

Image

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 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,
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
I think that it will be very difficult.
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++.
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

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.

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 »

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...
Yes, I didn't understand the elegance of your ideas. :oops:
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. :oops:
User avatar
JHPJHP
Addict
Addict
Posts: 2251
Joined: Sat Oct 09, 2010 3:47 am

Re: PureBasic Interface to OpenCV

Post by JHPJHP »

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.
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 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

Post by JHPJHP »

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.
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 StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
infratec
Always Here
Always Here
Posts: 7583
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: PureBasic Interface to OpenCV

Post by infratec »

:thumpup:

and

:respect:
Locked