Solved

use of OpenCV Library with DirectShow on Visual C++ .Net 2003 enviroment

Posted on 2006-06-13
6
1,548 Views
Last Modified: 2013-12-14
Hello,
Im trying to write a motion detection algorithm with my camera by using OpenCV graphic library. My camera unit actually is running through a video capture card and OpenCV lib does not provide that kind of camera sistem. As my understanding, only way to utilize OpenCV is using DirectShow. I found a web site "http://www.site.uottawa.ca/~laganier/tutorial/opencv+directshow/cvision.htm" which is about both openCV and directShow but all represented code examples were written in Visual C++ 6.0. I tried lots of way to convert examples into Visual C++ NET 2003 using managed c++, but i didnt.

So, can you help me to write this code in managed c++ or can you show me to way how to use OpenCV library with DirectShow.
0
Comment
Question by:ebnhuseyin
6 Comments
 
LVL 4

Accepted Solution

by:
fffej78 earned 250 total points
ID: 16900185
http://sourceforge.net/projects/directshownet/ might be of some help (it's a .NET binding for DirectShow).

As someone who has worked with DirectShow, I can tell you it' sgoing to be a huge pain in the butt to get OpenCV and DirectShow interacting with .NET.  The best option would be to buy the Visual C++ that doesn't spew out managed code, it might cost $100 or so, but it'll stop you getting a massive headache.

You'll need to write a series of DirectShow filters.  Your best starting point is:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directshow/htm/writingdirectshowfilters.asp

If you are lucky, then your camera already has a DirectShow filter and you just need to build the appropriate graph

http://msdn.microsoft.com/library/en-us/directshow/htm/capturegraphbuilder.asp?frame=true

So you'll grab a frame from the camera, do something and then send it upstream to a renderer.  You'll have to implement the "do something" filter yourself.  It'll take an image as input, and return an image as output.  Not sure what your algorithm does, maybe it highlights what is moving in the image.  

Check out http://www.hmelyoff.com/index.php?section=12 for some example motion detecting filters.  You should at least be able to use this to verify you have the general idea of things in the graph builder thing that you get with the DirectShow SDK.
0
 
LVL 4

Expert Comment

by:e_tadeu
ID: 16904735
Why do you want to use managed (.net/clr/interpreted) code, when you have the faster native API's? Just use the DirectX SDK and OpenCV directly on C++ :)
0
 
LVL 8

Expert Comment

by:mrblue
ID: 16906299
I think that the easiest way is to modify sample transform filter from DirectX SDK (for example <dxdir>\C++\DirectShow\Filters\Gargle).

You will have to modify "Transform()" method in the simplest case. Note that this filter derives from CTransInPlaceFilter what means it transforms data in-place. If you want to change frame format you will have to inherit from CTransformFilter.

Likely you will also have to modify CheckInputType.
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 4

Expert Comment

by:fffej78
ID: 16906571
To follow up with mrblue, I don't think you will be able to compile DirectShow filters as "managed C++", then need to be built using standard C++ as they are exposed as COM objects.
0
 
LVL 8

Expert Comment

by:mrblue
ID: 16906787
I far as I know .NET compiler supports also unmanaged code so at least compiling should't be a problem (correct me if I'm wrong).
0
 

Author Comment

by:ebnhuseyin
ID: 16908925
thanks guy for the answers. Actually my idiea to use managed c++, i thought to write event base application with opencv on NET platform. But when t tried to use source code which links is given above, i coudnt converted it into managed C++. Everything was written with old code system. Header files always were giving syntax error anyway.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need Tool Easily Convert Text to a quote string 5 32
C++ question 3 67
Embarcadero C++ builder XE10.1 Berlin TRegistry declaration 1 31
How do i run a c++ file? 15 31
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question