Ilia Gildin
Junior Member level 3
Hello
In this code I need to build a matrix where each column is the data of image_vec
how should I do it?
thanks
Ilia
Code:
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/opencv.hpp>
#include <thread>
#include <concurrent_queue.h>
#include <pipeline.h>
#include <time.h>
using namespace std;
using namespace cv;
int main()
{
CvCapture *capture=cvCaptureFromFile("C:\\test.mp4");
static const int length = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_COUNT); //250
static const int width = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH); //480
static const int height = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT); //360
static const int fps = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
Mat image;
Mat image_split[3];
Mat image_new;
Mat image_temp;
Mat image_vec = (Mat_<int>(1, width*height) << 0);
//Mat A = (Mat_<int>(length, width*height) << 0);
Mat A;
IplImage* frame;
for (int i = 0; i<length; i++)
{
frame = cvQueryFrame(capture);
if (!frame)
{
break;
}
image = cvarrToMat(frame);
split(image,image_split);
image_new = image_split[2];
image_vec = image_new.reshape(1, height*width);
auto column = image_vec.col(0);
//A.row(i) = image_vec;
column.copyTo(A(Range(i,i+1),Range(0,width*height)));
cout << "M = "<< endl << " " << A << endl << endl;
}
//cout << "M = "<< endl << " " << A << endl << endl;
cvReleaseCapture(&capture);
return 0;
}
how should I do it?
thanks
Ilia