Ask Your Question

Revision history [back]

Windows 10 VS 2015 opencv-3.2.0-dev opencv_ffmpeg320_64.dll OpenH264 Video Codec provided by Cisco Systems, Inc.

With this program I haven't got any problem (CAP_PROP_FOURCC: avc1)

vector<int> pos={1, 2,3,5,7,11,13,17,19,23,29,31,37,41,43 };
vector<Mat> frameSelec;
double x;
int fourcc=video.get(CAP_PROP_FOURCC);
string fourcc_str = format("%c%c%c%c", fourcc & 255, (fourcc >> 8) & 255, (fourcc >> 16) & 255, (fourcc >> 24) & 255);
cout << "CAP_PROP_FOURCC: " << fourcc_str << endl;
for (int j = 0, i = 0; j < pos.size(); i++)
{
    video >> frameVideo;
    if (i == pos[j])
    {
        frameSelec.push_back(frameVideo.clone());
        j++;
    }
}
video.set(CAP_PROP_POS_FRAMES, 0);
double minV[1],maxV[1];
for (int j = 0; j < pos.size(); j++)
{
    video.set(CAP_PROP_POS_FRAMES, pos[j]);
    video >> frameVideo;
    Mat d;
    imshow("flu", frameVideo);
    imshow("fpo", frameSelec[j]);
    subtract(frameVideo,frameSelec[j],d,noArray(),CV_16S);
    d = d.reshape(1);
    minMaxLoc(d,minV,maxV);
    for (int k = 0; k < 1; k++)
    {
        cout<<minV[k]<<"\t"<<maxV[k]<<"\t";
    }
    cout<<"\n";
    waitKey();
}

Windows 10 VS 2015 opencv-3.2.0-dev opencv_ffmpeg320_64.dll OpenH264 Video Codec provided by Cisco Systems, Inc.

With this program I haven't got any problem (CAP_PROP_FOURCC: avc1)

vector<int> pos={1, 2,3,5,7,11,13,17,19,23,29,31,37,41,43 };
vector<Mat> frameSelec;
double x;
VideoCapture video("b.mp4");
if (!video.isOpened())
{
    cout << "Video introuvable";
    return 0;
}
Mat frameVideo;
int fourcc=video.get(CAP_PROP_FOURCC);
string fourcc_str = format("%c%c%c%c", fourcc & 255, (fourcc >> 8) & 255, (fourcc >> 16) & 255, (fourcc >> 24) & 255);
cout << "CAP_PROP_FOURCC: " << fourcc_str << endl;
for (int j = 0, i = 0; j < pos.size(); i++)
{
    video >> frameVideo;
    if (i == pos[j])
    {
        frameSelec.push_back(frameVideo.clone());
        j++;
    }
}
video.set(CAP_PROP_POS_FRAMES, 0);
double minV[1],maxV[1];
for (int j = 0; j < pos.size(); j++)
{
    video.set(CAP_PROP_POS_FRAMES, pos[j]);
    video >> frameVideo;
    Mat d;
    imshow("flu", frameVideo);
    imshow("fpo", frameSelec[j]);
    subtract(frameVideo,frameSelec[j],d,noArray(),CV_16S);
    d = d.reshape(1);
    minMaxLoc(d,minV,maxV);
    for (int k = 0; k < 1; k++)
    {
        cout<<minV[k]<<"\t"<<maxV[k]<<"\t";
    }
    cout<<"\n";
    waitKey();
}

Windows 10 VS 2015 opencv-3.2.0-dev opencv_ffmpeg320_64.dll OpenH264 Video Codec provided by Cisco Systems, Inc.

With this program I haven't got any problem (CAP_PROP_FOURCC: avc1)

vector<int> pos={1, 2,3,5,7,11,13,17,19,23,29,31,37,41,43 };
vector<Mat> frameSelec;
VideoCapture video("b.mp4");
if (!video.isOpened())
{
    cout << "Video introuvable";
    return 0;
}
Mat frameVideo;
int fourcc=video.get(CAP_PROP_FOURCC);
string fourcc_str = format("%c%c%c%c", fourcc & 255, (fourcc >> 8) & 255, (fourcc >> 16) & 255, (fourcc >> 24) & 255);
cout << "CAP_PROP_FOURCC: " << fourcc_str << endl;
for (int j = 0, i = 0; j < pos.size(); i++)
{
    video >> frameVideo;
    if (i == pos[j])
    {
        frameSelec.push_back(frameVideo.clone());
        j++;
    }
}
video.set(CAP_PROP_POS_FRAMES, 0);
double minV[1],maxV[1];
for (int j = 0; j < pos.size(); j++)
{
    video.set(CAP_PROP_POS_FRAMES, pos[j]);
pos[j]-3);
    for (int kk = 0; kk < 6; kk++)
    {
        video >> frameVideo;
     Mat d;
     imshow("flu", frameVideo);
     imshow("fpo", frameSelec[j]);
     subtract(frameVideo,frameSelec[j],d,noArray(),CV_16S);
     d = d.reshape(1);
     minMaxLoc(d,minV,maxV);
    for (int k     if (abs(minV[0]) + abs(maxV[0]) == 0)
        {
            cout<<"Min for frame "<< pos[j] - 3+kk<<"expected "<<pos[j]<<" \t"<<minV[0]<<"\t"<<maxV[0]<<"\t";
            cout<<"\n";
        }
        if (kk == 3)
        {
            cout << "error for frame " << pos[j] - 3 + kk <<  " \t" << minV[0] << "\t" << maxV[0] << "\t";
               cout << "\n";

        }

        d=abs(d);
        d.convertTo(d,CV_8U);
        d = 0; k < 1; k++)
    {
        cout<<minV[k]<<"\t"<<maxV[k]<<"\t";
d.reshape(3, frameVideo.rows);
        imshow("diff", d);
    }
    cout<<"\n";
    waitKey();
    waitKey(10);
}

Results are

CAP_PROP_FOURCC: avc1
Min for frame 50expected 50     0       0
error for frame 50      0       0
Min for frame 100expected 100   0       0
error for frame 100     0       0
Min for frame 149expected 150   0       0
error for frame 150     -166    198
Min for frame 249expected 250   0       0
error for frame 250     -162    144
Min for frame 349expected 350   0       0
error for frame 350     -225    251
Min for frame 550expected 550   0       0
error for frame 550     0       0
Min for frame 649expected 650   0       0
error for frame 650     -204    217
Min for frame 850expected 850   0       0
error for frame 850     0       0
Min for frame 950expected 950   0       0
error for frame 950     0       0
Min for frame 1149expected 1150         0       0
error for frame 1150    -213    204
Min for frame 1449expected 1450         0       0
error for frame 1450    -166    148
error for frame 1550    -217    194
Min for frame 1551expected 1550         0       0
Min for frame 1849expected 1850         0       0
error for frame 1850    -215    221
Min for frame 2050expected 2050         0       0
error for frame 2050    0       0
Min for frame 2150expected 2150         0       0
error for frame 2150    0       0

Windows 10 VS 2015 opencv-3.2.0-dev opencv_ffmpeg320_64.dll OpenH264 Video Codec provided by Cisco Systems, Inc.

With this program I haven't haven't got any problem any some problems (CAP_PROP_FOURCC: avc1)

vector<int> pos={1, 2,3,5,7,11,13,17,19,23,29,31,37,41,43 };
vector<Mat> frameSelec;
VideoCapture video("b.mp4");
if (!video.isOpened())
{
    cout << "Video introuvable";
    return 0;
}
Mat frameVideo;
int fourcc=video.get(CAP_PROP_FOURCC);
string fourcc_str = format("%c%c%c%c", fourcc & 255, (fourcc >> 8) & 255, (fourcc >> 16) & 255, (fourcc >> 24) & 255);
cout << "CAP_PROP_FOURCC: " << fourcc_str << endl;
for (int j = 0, i = 0; j < pos.size(); i++)
{
    video >> frameVideo;
    if (i == pos[j])
    {
        frameSelec.push_back(frameVideo.clone());
        j++;
    }
}
video.set(CAP_PROP_POS_FRAMES, 0);
double minV[1],maxV[1];
for (int j = 0; j < pos.size(); j++)
{
    video.set(CAP_PROP_POS_FRAMES, pos[j]-3);
    for (int kk = 0; kk < 6; kk++)
    {
        video >> frameVideo;
        Mat d;
        imshow("flu", frameVideo);
        imshow("fpo", frameSelec[j]);
        subtract(frameVideo,frameSelec[j],d,noArray(),CV_16S);
        d = d.reshape(1);
        minMaxLoc(d,minV,maxV);
        if (abs(minV[0]) + abs(maxV[0]) == 0)
        {
            cout<<"Min for frame "<< pos[j] - 3+kk<<"expected "<<pos[j]<<" \t"<<minV[0]<<"\t"<<maxV[0]<<"\t";
            cout<<"\n";
        }
        if (kk == 3)
        {
            cout << "error for frame " << pos[j] - 3 + kk <<  " \t" << minV[0] << "\t" << maxV[0] << "\t";
               cout << "\n";

        }

        d=abs(d);
        d.convertTo(d,CV_8U);
        d = d.reshape(3, frameVideo.rows);
        imshow("diff", d);
    }
        waitKey(10);
}

Results for video : https://www.youtube.com/watch?v=tnWP2Emps1M are

CAP_PROP_FOURCC: avc1
Min for frame 50expected 50     0       0
error for frame 50      0       0
Min for frame 100expected 100   0       0
error for frame 100     0       0
Min for frame 149expected 150   0       0
error for frame 150     -166    198
Min for frame 249expected 250   0       0
error for frame 250     -162    144
Min for frame 349expected 350   0       0
error for frame 350     -225    251
Min for frame 550expected 550   0       0
error for frame 550     0       0
Min for frame 649expected 650   0       0
error for frame 650     -204    217
Min for frame 850expected 850   0       0
error for frame 850     0       0
Min for frame 950expected 950   0       0
error for frame 950     0       0
Min for frame 1149expected 1150         0       0
error for frame 1150    -213    204
Min for frame 1449expected 1450         0       0
error for frame 1450    -166    148
error for frame 1550    -217    194
Min for frame 1551expected 1550         0       0
Min for frame 1849expected 1850         0       0
error for frame 1850    -215    221
Min for frame 2050expected 2050         0       0
error for frame 2050    0       0
Min for frame 2150expected 2150         0       0
error for frame 2150    0       0

Windows 10 VS 2015 opencv-3.2.0-dev opencv_ffmpeg320_64.dll OpenH264 Video Codec provided by Cisco Systems, Inc.

With this program I haven't got any some problems (CAP_PROP_FOURCC: avc1)

vector<int> pos={1, 2,3,5,7,11,13,17,19,23,29,31,37,41,43 pos={1*50, 2 * 50,3 * 50,5 * 50,7 * 50,11 * 50,13 * 50,17 * 50,19 * 50,23 * 50,29 * 50,31 * 50,37 * 50,41 *50,43 * 50 };
vector<Mat> frameSelec;
VideoCapture video("b.mp4");
if (!video.isOpened())
{
    cout << "Video introuvable";
    return 0;
}
Mat frameVideo;
int fourcc=video.get(CAP_PROP_FOURCC);
string fourcc_str = format("%c%c%c%c", fourcc & 255, (fourcc >> 8) & 255, (fourcc >> 16) & 255, (fourcc >> 24) & 255);
cout << "CAP_PROP_FOURCC: " << fourcc_str << endl;
for (int j = 0, i = 0; j < pos.size(); i++)
{
    video >> frameVideo;
    if (i == pos[j])
    {
        frameSelec.push_back(frameVideo.clone());
        j++;
    }
}
video.set(CAP_PROP_POS_FRAMES, 0);
double minV[1],maxV[1];
for (int j = 0; j < pos.size(); j++)
{
    video.set(CAP_PROP_POS_FRAMES, pos[j]-3);
    for (int kk = 0; kk < 6; kk++)
    {
        video >> frameVideo;
        Mat d;
        imshow("flu", frameVideo);
        imshow("fpo", frameSelec[j]);
        subtract(frameVideo,frameSelec[j],d,noArray(),CV_16S);
        d = d.reshape(1);
        minMaxLoc(d,minV,maxV);
        if (abs(minV[0]) + abs(maxV[0]) == 0)
        {
            cout<<"Min for frame "<< pos[j] - 3+kk<<"expected "<<pos[j]<<" \t"<<minV[0]<<"\t"<<maxV[0]<<"\t";
            cout<<"\n";
        }
        if (kk == 3)
        {
            cout << "error for frame " << pos[j] - 3 + kk <<  " \t" << minV[0] << "\t" << maxV[0] << "\t";
               cout << "\n";

        }

        d=abs(d);
        d.convertTo(d,CV_8U);
        d = d.reshape(3, frameVideo.rows);
        imshow("diff", d);
    }
        waitKey(10);
}

Results for video : https://www.youtube.com/watch?v=tnWP2Emps1M are

CAP_PROP_FOURCC: avc1
Min for frame 50expected 50     0       0
error for frame 50      0       0
Min for frame 100expected 100   0       0
error for frame 100     0       0
Min for frame 149expected 150   0       0
error for frame 150     -166    198
Min for frame 249expected 250   0       0
error for frame 250     -162    144
Min for frame 349expected 350   0       0
error for frame 350     -225    251
Min for frame 550expected 550   0       0
error for frame 550     0       0
Min for frame 649expected 650   0       0
error for frame 650     -204    217
Min for frame 850expected 850   0       0
error for frame 850     0       0
Min for frame 950expected 950   0       0
error for frame 950     0       0
Min for frame 1149expected 1150         0       0
error for frame 1150    -213    204
Min for frame 1449expected 1450         0       0
error for frame 1450    -166    148
error for frame 1550    -217    194
Min for frame 1551expected 1550         0       0
Min for frame 1849expected 1850         0       0
error for frame 1850    -215    221
Min for frame 2050expected 2050         0       0
error for frame 2050    0       0
Min for frame 2150expected 2150         0       0
error for frame 2150    0       0