Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Opencv matrix of vectors

Status
Not open for further replies.

Ilia Gildin

Junior Member level 3
Joined
Sep 27, 2014
Messages
26
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
184
Hello
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;
}
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
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top