Ask Your Question

Revision history [back]

not really an answer.. more the way to eventually one..

i have tested the what happens with some debugging statements in the code: first i added some debug statements in cap_libv4l.cpp#L1414

case CV_CAP_PROP_POS_MSEC:
    if (capture->FirstCapture) {
        fprintf( stderr, "VIDEOIO INFO: V4L: CV_CAP_PROP_POS_MSEC==0 caused by capture->FirstCapture == 1");
        return 0;
    } else {
        //would be maximally numerically stable to cast to convert as bits, but would also be counterintuitive to decode
        return 1000 * capture->timestamp.tv_sec + ((double) capture->timestamp.tv_usec) / 1000;
    }
    break;

and in cap_v4l.cpp#L1651

if(property_id == CV_CAP_PROP_POS_MSEC) {
    if (capture->FirstCapture) {
        fprintf( stderr, "VIDEOIO INFO: V4L2: CV_CAP_PROP_POS_MSEC==0 caused by capture->FirstCapture == 1\n");
        return 0;
    } else {
        return 1000 * capture->timestamp.tv_sec + ((double) capture->timestamp.tv_usec) / 1000;
    }
}

recompiled OpenCV and tested with an simple cam viewer. found that with the current setup it is using cap_v4l.cpp - and that only the first time my debugmessage was triggerd.

so i added some some more debug output to cap_v4l.cpp L1651:

if(property_id == CV_CAP_PROP_POS_MSEC) {
    if (capture->FirstCapture) {
        fprintf( stderr, "VIDEOIO INFO: V4L2: CV_CAP_PROP_POS_MSEC==0 caused by capture->FirstCapture == 1\n");
        return 0;
    } else {
        fprintf( stderr, "VIDEOIO INFO: V4L2: CV_CAP_PROP_POS_MSEC:\n");
        fprintf( stderr, "\tcapture->timestamp.tv_sec %ld\n", capture->timestamp.tv_sec);
        fprintf( stderr, "\tcapture->timestamp.tv_usec %ld\n", capture->timestamp.tv_usec);
        return 1000 * capture->timestamp.tv_sec + ((double) capture->timestamp.tv_usec) / 1000;
    }
}

with this i get

VIDEOIO INFO: V4L2: CV_CAP_PROP_POS_MSEC:
     capture->timestamp.tv_sec 0
     capture->timestamp.tv_usec 0
cv::CAP_PROP_POS_MSEC = 0

the last line comes from my app.. so the capture->timestamp contains 0. it is set in cap_v4l.cpp#L868 directly from the buffer. so it seams OpenCV does not get a timestamp information from the ioctl call back :-(

now at this point i have no idea how to go on... could be a problem in the v4l2 implementation??