Ask Your Question
0

processing Video frames

asked 2013-04-07 14:41:53 -0600

william13200 gravatar image

updated 2013-04-11 14:20:01 -0600

Hi there, i've been struggling for the last month trying to get it working.. i thought i could use some help:

i'm using windows 7 64bits with VS12 (from dreamspark)

i've installed opencv at C:Root and also Cmake.

The first pb i get is that, when i'm running cmake i get this error:

CMake was unable to find a build program corresponding to "Visual Studio 9 2008 Win64". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.strong text

when i click on configure i only have choices for VS5 to 9, not VS12 nor 11. everysingle option gives me the same error.

i guess i have a problem with my VS12 compiler. I think i've added the opencv binaries the proper way (x64 x86 bin in sys.path), but what seems weird is that in my system path, i don't have anything mentionning VS12 nor VS11. I've noticed in my program files i only have VS11. Are they using the same compiler?

I need help because i've been stuck for too long, thanks a lot if anyone can help me out..

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2013-04-08 02:48:15 -0600

Is it really necessary to build openCV yourself? Most functionality is provided in the 2.4.4 prebuilt binaries for Windows and Visual Studio. This will work perfectly, since it is running on my system here.

You can download them from the main download page and just set the correct linker options towards the necessary dll's for your project.

http://opencv.org/downloads.html

However it seems that there are actually some problems with VS2012 and OpenCV. Please read through this topic:

http://answers.opencv.org/question/6495/visual-studio-2012-and-rtlfreeheap-error/#6603

edit flag offensive delete link more

Comments

thanks a lot for your answer. I'll try doing this way. what you mean is only using openCv as a pure library? I tried building a VS2012 basic application but it seems libraries can't work

What do you call prebuild binaries? i mean in which folders are they supposed to be? is it /opencv/build/x86/vc11/ bin lib and static lib in my case?

william13200 gravatar imagewilliam13200 ( 2013-04-08 12:05:36 -0600 )edit

Just go away from old C-style code and switch to C++ it will make your life a lot easier :) And a warning is no error, it is a warning which you can simply ignore. There have been newer filecommunication functions in C and C++, but some of the older functions still use the fopen functionality. For C++ go to : http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html

StevenPuttemans gravatar imageStevenPuttemans ( 2013-04-08 12:36:30 -0600 )edit
1

i've been following these tutorials and it's the exact solution i needed. Thanks A LOT for your help, it's been at least a month i tried to get it working.

william13200 gravatar imagewilliam13200 ( 2013-04-08 12:37:54 -0600 )edit
1

Then please accept the answer so that your topic shows solved and people can find solved solutions faster :)

StevenPuttemans gravatar imageStevenPuttemans ( 2013-04-08 13:01:14 -0600 )edit

and how do i do that?? :/ i'm trying to add a new comment for another pb, have a look up there, not creating another thread

william13200 gravatar imagewilliam13200 ( 2013-04-11 15:07:05 -0600 )edit

You accept a solution by clicking the v button :) It then becomes green.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-04-11 15:24:16 -0600 )edit
1

Ok (laugh) i found it :p could you please have a look above. I just didn't want to create another thread

william13200 gravatar imagewilliam13200 ( 2013-04-12 00:19:30 -0600 )edit
0

answered 2013-04-11 14:25:36 -0600

william13200 gravatar image

updated 2013-04-11 14:28:46 -0600

Hi there i've been playing a little bit discovering openCv on VS12, everything works fine for me concerning image processing. But i have a problem for processing video: i'm following basic tutorials, but when i compile, i only get one single frame through the video input. Where could this come from? I think i have a problem handling my frame, but i've been stricly following tutorials, this is what i write:

void main() { //example from a book

cv::VideoCapture capture(0);

if (!capture.isOpened())

    std::cout<<"not opened" <<std::endl;

// Get the frame rate

double rate= capture.get(CV_CAP_PROP_FPS);

bool stop(false);

cv::Mat frame; // current video frame

cv::namedWindow("Extracted Frame");

// Delay between each frame in ms // corresponds to video frame rate

int delay= 1000/rate;

// for all frames in video

while (!stop) {

// read next frame if any

    if (!capture.read(frame))
        break;

    cv::imshow("Extracted Frame",frame);

// introduce a delay // or press key to stop

    if (cv::waitKey(delay)>=0)
        stop= true;

} // Close the video file. // Not required since called by destructor capture.release(); }

//another version i personnaly wrote void main (void){ bool stop; stop = false; cv::VideoCapture capture (0); //capture from the webcam

if(capture.isOpened() == false ){
    std::cout<< "Capture Error" <<std::endl;
}//test if opned

cv::Mat frame;
cv::namedWindow("w");

double rate= capture.get(CV_CAP_PROP_FPS);


while (stop == false){
    frame=capture.read();
    if (!capture.read(frame))
        break;


    if (cvWaitKey() ){
        stop = true;
    }

    cv::imshow("w",frame);

}// chose while
capture.release();
cvDestroyWindow("w");

}

everytime i get the same thing: One single image from the cam does appear, and then i can push any key to stop, but i dont get a video frame

edit flag offensive delete link more

Comments

The problem is the location of your waitKey command. You have to know that visualizing a Matrix (which is in fact an image) always requires a waiting time in order to be able to call the internal repaint function of the window. If you don't do this, the image will not get visualized.

So try to change this line:

 cv::imshow("w",frame); waitKey(20); // about 20 msec needed for processing

Also there is an internal loop. You are telling to waitKey() forever, since there is no time limit: This will mean that when you press any key, the boolean stop is set to true and you jump out of the loop. Try to change it to something like:

  int key = waitKey();     
  if ( key == 27 ){ //ASCI code for ESC char
    stop = true;
  }

This will only let you exit the loop at ESC.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-04-12 02:16:24 -0600 )edit

And next time, do open a new question. It is better for new users to find a single question and answer inside a topic.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-04-12 02:18:36 -0600 )edit
1

Ok i'm just used to do not waste space in forums in general :p thanks a lot guys you are great. That wasnt obvious for me that waitKey was used to create the delay to process the video frames.

william13200 gravatar imagewilliam13200 ( 2013-04-12 06:25:46 -0600 )edit

Took me some time to figure it out also :) But once you know it, it solves a lot of problems :)

StevenPuttemans gravatar imageStevenPuttemans ( 2013-04-12 06:32:07 -0600 )edit

Question Tools

Stats

Asked: 2013-04-07 14:41:53 -0600

Seen: 585 times

Last updated: Apr 11 '13