1 | initial version |
Tell me how those different channels look like.
int main (int argc, char **argv)
{
if (argc !=2)
{
std::cout << "USE: " << argv[0] << " <video-filename>" << std::endl;
return -1;
}
//Open the video that you pass from the command line
cv::VideoCapture cap(argv[1]);
if (!cap.isOpened())
{
std::cerr << "ERROR: Could not open video " << argv[1] << std::endl;
return -1;
}
int frame_count = 0;
bool should_stop = false;
while(!should_stop)
{
cv::Mat frame;
cap >> frame; //get a new frame from the video
if (frame.empty())
{
should_stop = true; //we arrived to the end of the video
continue;
}
vector<Mat> matVector;
split( frame, matVector );
char filename[64];
char filename2[64];
char filename3[64];
sprintf(filename, "frame_%06d_b.jpg", frame_count);
sprintf(filename2, "frame_%06d_g.jpg", frame_count);
sprintf(filename3, "frame_%06d_r.jpg", frame_count);
cv::imwrite(filename, matVector[0]);
cv::imwrite(filename2, matVector[1]);
cv::imwrite(filename3, matVector[2]);
frame_count++;
}
return 0;
}
2 | No.2 Revision |
Tell me how those different channels look like.
int main (int argc, char **argv)
{
if (argc !=2)
{
std::cout << "USE: " << argv[0] << " <video-filename>" << std::endl;
return -1;
}
//Open the video that you pass from the command line
cv::VideoCapture cap(argv[1]);
if (!cap.isOpened())
{
std::cerr << "ERROR: Could not open video " << argv[1] << std::endl;
return -1;
}
int frame_count = 0;
bool should_stop = false;
while(!should_stop)
{
cv::Mat frame;
cap >> frame; //get a new frame from the video
if (frame.empty())
{
should_stop = true; //we arrived to the end of the video
continue;
}
vector<Mat> vector<cv::Mat> matVector;
split( cv::split( frame, matVector );
char filename[64];
char filename2[64];
char filename3[64];
sprintf(filename, "frame_%06d_b.jpg", frame_count);
sprintf(filename2, "frame_%06d_g.jpg", frame_count);
sprintf(filename3, "frame_%06d_r.jpg", frame_count);
cv::imwrite(filename, matVector[0]);
cv::imwrite(filename2, matVector[1]);
cv::imwrite(filename3, matVector[2]);
frame_count++;
}
return 0;
}
3 | No.3 Revision |
Tell me how those different channels look like.
int main (int argc, char **argv)
{
if (argc !=2)
{
std::cout << "USE: " << argv[0] << " <video-filename>" << std::endl;
return -1;
}
//Open the video that you pass from the command line
cv::VideoCapture cap(argv[1]);
if (!cap.isOpened())
{
std::cerr << "ERROR: Could not open video " << argv[1] << std::endl;
return -1;
}
int frame_count = 0;
bool should_stop = false;
while(!should_stop)
{
cv::Mat frame;
cap >> frame; //get a new frame from the video
if (frame.empty())
(cap.grab() {
cap.retrieve(frame, 1);
char filename[64];
sprintf(filename, "frame_%06d.jpg", frame_count);
cv::imwrite(filename, frame);
frame_count++;
} else {
should_stop = true; //we arrived to the end of the video
true;
continue;
}
vector<cv::Mat> matVector;
cv::split( frame, matVector );
char filename[64];
char filename2[64];
char filename3[64];
sprintf(filename, "frame_%06d_b.jpg", frame_count);
sprintf(filename2, "frame_%06d_g.jpg", frame_count);
sprintf(filename3, "frame_%06d_r.jpg", frame_count);
cv::imwrite(filename, matVector[0]);
cv::imwrite(filename2, matVector[1]);
cv::imwrite(filename3, matVector[2]);
frame_count++;
}
}
return 0;
}
4 | No.4 Revision |
Tell me how those different channels look like.
int main (int argc, char **argv)
{
if (argc !=2)
{
std::cout << "USE: " << argv[0] << " <video-filename>" << std::endl;
return -1;
}
//Open the video that you pass from the command line
cv::VideoCapture cap(argv[1]);
if (!cap.isOpened())
{
std::cerr << "ERROR: Could not open video " << argv[1] << std::endl;
return -1;
}
int frame_count = 0;
bool should_stop = false;
while(!should_stop)
{
cv::Mat frame;
if (cap.grab() {
cap.retrieve(frame, 1);
char filename[64];
sprintf(filename, "frame_%06d.jpg", frame_count);
cv::imwrite(filename, frame);
frame_count++;
} else {
should_stop = true;
continue;
}
}
return 0;
}