Ask Your Question

ararr's profile - activity

2017-04-29 08:34:02 -0500 received badge  Famous Question (source)
2015-02-20 06:37:58 -0500 received badge  Taxonomist
2012-07-31 09:37:39 -0500 commented answer video properies give wrong results.

sorry it took so long to answer. opencv 2.4.1 i am using and the problem exists only with avi files with h264 encoding. When I change them to mpg things seem to work but the problem is that the videos increase 10 times their size. So any ideas?

2012-07-29 05:47:49 -0500 asked a question video properies give wrong results.

In my program the video properties give me wrong results for the frame count and the msec of the frames in the video. e I know that it must be an opencv problem but I was wondering if I can compile from scratch opencv so that opencv can correctly recognize the video properties.

So I am asking is there a way to configure the ffmpeg or libx264 support so that opencv reads the correct properties?

I am asking because I do not want to do it through ffmpeg apis because i have better understanding of Opencv

2012-07-21 16:10:18 -0500 answered a question Video propeties different.conflicting results

thanks for the answer but in mt project I do not need the frame count.

I just need the actual frame timestamp.

the property CV_CAP_PROP_POS__MSEC is giving me wrong results, they are in accordance with the frame count as measured from inside the loop. For example,for my 17min video, the max value MSEC is giving me is 202 sec.

Is there a way to adjust this as reference to my actual video length?

I mean at MSEC 101sec how can I adjust it to give me 8.5 min?

2012-07-21 16:04:07 -0500 answered a question Video propeties different.conflicting results

thnaks for the answer, but I really do not care so much about the count of the frames in my project. I want to have a way to extract the real timestamp of the frame. CVCAPPROPPOSMSEC is giving me wrong results, they are in accordance with the count of the frames as measured inside the loop.

for example for a 17min video max value of MSEC that I get is 202 sec.

Is there a way to adjust this as reference to the actual video time?

2012-07-21 02:25:51 -0500 asked a question Video propeties different.conflicting results

hi I try to play a video file and I get mconfilctig results from the getPropery from VideoCapture Class.

from the get propety frame count in my video I get 31222 frames. But fromthe loop in main, mesauring the i variable I get that there are only 6063 frames? My fps is 30 frames per sec.

So which is right? Maybe the get property gets value from the video file without measuring but by checking the headers of the video? I don't know.Cannot understad why. Using OpenCV 2.4.1 and ubuntu

Update::even with the tree.avi video that comes with openCV source it gives different results. So it is not a problem of my video file..

code:

#include <stdio.h>
#include "cv.h"
#include "highgui.h"

int main( int argc, char** argv )
{
    double frameCount;
    IplImage  *frame;
    int       key;

    /* load the AVI file */
    CvCapture *capture = cvCaptureFromAVI( argv[1] );

    /* always check */
    if( !capture ) return 1;


    int i=0;

    /* display video */
    cvNamedWindow( "video", 0 );

    while( key != 'q' ) {
        /* get a frame */
        frame = cvQueryFrame( capture );
        if(!frame){printf("no frame or video finished");}
        i++;

        /* always check */
        if( !frame ) break;

        /* display frame */
        cvShowImage( "video", frame );

        /* quit if user press 'q' */
        key = cvWaitKey( 1);
    }
    frameCount=cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_COUNT);
    fps = ( int )cvGetCaptureProperty( capture, CV_CAP_PROP_FPS );
    printf("fps is %d frames per second\n",fps);
    printf("frame count as measured in for loop %d\n",i);
    printf("frame count as mesaured from property %f\n",frameCount);
    /* free memory */
    cvReleaseCapture( &capture );
    cvDestroyWindow( "video" );

    return 0;
}
2012-07-20 17:51:20 -0500 commented question VideoCapture properties give conflicting results

OpenCV 2.4.1 version, ubuntu any ideas?

2012-07-20 02:52:41 -0500 received badge  Popular Question (source)
2012-07-19 22:38:15 -0500 received badge  Notable Question (source)
2012-07-19 04:09:51 -0500 asked a question VideoCapture properties give conflicting results

I have a video file which is 17min:20sec long.

With fps=30 which I get from CV-CAP-PROP-FPS property of VideoCapture class, normally I must have

(17min:20sec=1040sec) *30 (frames/sec)=31200 frames, right?

My CV-CAP-PROP-FRAME-COUNT property gives me 31222 which is right.

The problem is that if I have a variable as a counter and increment it every time that the program fetches the next frame of the video file(at the beginning of a for loop), in the end the counter value is 6062,which means it parsed only 6062 frames.

The even more strange is the CV-CAP-PROP-POS-MSEC property corresponds well according to the fps,meaning that every 1000msec I have 30 new frames, but the overall number of frames is again 6062. Also the CV-CAP-PROP-POS-FRAMES is giving me the same result 6062 frames.

But if the frames are only 6062 and fps 30, means that it gets only 202,07 sec(=3min:22sec)

The thing is that what I see in the program is that it dipslays the video relative fast(i thought it was because of the cv_waitkey funtion that I have set it to wait 10msec).And the relaity is that the program displays all the video from the beggining to the end but much faster.

So can anybody tell me?

Am I losing frames and information or I have done wrong calculations and it is right??

2012-07-19 03:32:30 -0500 received badge  Popular Question (source)
2012-07-19 02:40:04 -0500 received badge  Student (source)
2012-07-18 16:48:11 -0500 asked a question How to save opencv data in Excel format?

I want to take some information from opencv program and then store it in a file that later can be read by microsoft excel program or even by openoffice and libreOffice.

The information that I need to save is a char variable that takes a value from a function that I wrote, and the other variable is double and represents a property that I take from the VideoCapture class.

In the excel format I want to have a 2 column table that in the first position should be the videoCapture propery(timestamp) and the other column to have the value of the char that I want.

My question is if this can happen though saving my data in a .xml or .yml format that I can do with the use of OpenCV FileStorage class in a way that my file is ready for reading by excel.

Anybody has any idea how do I need to save my data in the xml file ready to read from excel??

2012-07-15 09:23:58 -0500 received badge  Notable Question (source)
2012-07-14 12:20:56 -0500 received badge  Popular Question (source)
2012-07-14 12:20:15 -0500 answered a question select ROI with mouse and display video. Strange problem

thank you very much that solves my problem. I had also tried with CvRect but with no success.

2012-07-14 12:18:48 -0500 received badge  Scholar (source)
2012-07-14 00:14:35 -0500 received badge  Editor (source)
2012-07-14 00:13:18 -0500 asked a question select ROI with mouse and display video. Strange problem

I need to display a video file and then select with mouse the region that I need and then in the same or another window to continue displaying the video but only in the specific region that I selected.

I am able to do it with the following code, but only if I have webcam as video input. when I take input a video file it can no do it. I have searched around and I have not been able to detect the problem any ideas why my code does not work with video file and works only with webcam input?

how can I do it for video??

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <cv.h>
#include <highgui.h>

IplImage* frame, * img1;
CvPoint point;
int drag = 0;
CvCapture *capture = 0;
int key = 0;

 void mouseHandler(int event, int x, int y, int flags, void* param)
{
/* user press left button */
if (event == CV_EVENT_LBUTTONDOWN && !drag)
{
point = cvPoint(x, y);
drag = 1;
}
/* user drag the mouse */
if (event == CV_EVENT_MOUSEMOVE && drag)
{
img1 = cvCloneImage(frame);
cvRectangle(img1,point,cvPoint(x, y),CV_RGB(255, 0, 0),1,8,0);
cvShowImage("result", img1);
}
/* user release left button */
if (event == CV_EVENT_LBUTTONUP && drag)
{
cvSetImageROI(frame,cvRect(point.x,point.y,x-point.x,y-point.y));
cvShowImage("result", frame);
drag = 0;
}

/* user click right button: reset all */
if (event == CV_EVENT_RBUTTONUP)
{
drag = 0;
}
}

int main(int argc, char *argv[])
{
capture = cvCaptureFromCAM( 0 ); /*here when I write cvCaptureFromAVI it does not work */
if ( !capture ) {
printf("Cannot open initialize webcam!\n" );
exit(0);
}

/* create a window for the video */ 
cvNamedWindow( "result", CV_WINDOW_AUTOSIZE );

while( key != 'q' )
{
int c;
frame = cvQueryFrame( capture );
cvSetMouseCallback("result", mouseHandler, NULL);
c = cvWaitKey(10);
if( (char) c== 'r' ){ cvResetImageROI(frame);}
cvShowImage("result", frame);
}
cvDestroyWindow("result");
cvReleaseImage(&frame);
cvReleaseImage(&img1);
return 0;
}