mat

Concatenating string names of variables matlabfile in R

烈酒焚心 提交于 2019-12-12 04:36:25
问题 I have matlab files with an integer in each name of my variables inside (except the first one). I want to loop to concatenate the name of the integers. There is my code: library('R.matlab') mat <- readMat('SeriesContPJM.mat') #str(mat) #typeof(mat) #mat[[1]] write.csv(mat$vol.PJM$data[[4]][[1]], "PJM.csv") i = 2 while (i < 7) { write.csv(get(paste("mat$vol.PJM", as.character(i), "$data[[4]][[1]]", sep = "")), paste(paste("PJM", as.character(i), sep="_"), "csv", sep =".")) i = i + 1 } I have

Conversion between opencv mat and CImage

老子叫甜甜 提交于 2019-12-12 03:31:14
问题 I am looking for an efficient way for converting an image stored in opencv Mat variable to a CImage object (CBitmap would be good as well). By efficient I mean both fast, and 'short-spelled'. my extended search resulted with finding code which is manually writing bitmap headers and data to the object, which i'd like to avoid, as i do not quite understand what is going on there. to make things worse it looks a little bit deprecated and produces runtime errors... (i believe i obtained it here:

Java OpenCV - detecting ROI, creating submat and copy to original mat

[亡魂溺海] 提交于 2019-12-12 03:13:32
问题 I'm trying to blur the faces of all people detected by the webcam. The problem is that when the webcam detect a face the program shows the crop mat with the blur face. I tried to put the blur face into the original mat but it doesn't work. for(Rect rect : faces.toArray()){ Imgproc.rectangle(frame, rect.tl(), rect.br(), new Scalar(0,0,255),3); Rect rectCrop = new Rect(rect.x, rect.y , rect.width, rect.height); Mat imageROI = grayFrame.submat(rectCrop); //frame is the original mat with the

Convert std::list to cv::Mat in C++ using OpenCV

无人久伴 提交于 2019-12-12 02:57:14
问题 I'm trying to solve an equation system using SVD: cv::SVD::solveZ(A, x); , but A needs to be a Matrix. OpenCV doesn't offer any convertion of a std::list to cv::Mat . So my question is, whether there is a smart way to convert it without having to convert the std::list to a std::vector before. The Matrix A is a 3xN matrix. My list contains N cv::Point3d elements. My code looks something like this: std::list<cv::Point3d> points; // length: N cv::Mat A = cv::Mat(points).reshape(1); // that's how

c++ OpenCV Turn a Mat into a 1 Dimensional Array

旧时模样 提交于 2019-12-12 01:55:49
问题 I have this Mat : Mat testDataMat(386, 2, CV_32FC1, testDataFloat); Which takes in from: float testDataFloat[386][2]; But I can't figure out how to turn it into a 1 Dimensional Array. Any help? 回答1: sample includes: direct method to convert from float 2d array to float 1d array. way to create a cv::Mat from 2D float array way to create 1D float array from a 2D cv::Mat that has no padding (e.g. stepsize = size of a single row) This one works for me: int main() { const int width = 2; const int

OpenCV get a copy of even rows of a Mat

北城以北 提交于 2019-12-11 20:22:02
问题 I would like to get the even rows/cols of a mat of 3 channels, something like this: A = 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 result = 1 1 1 1 1 1 How to can I do this using openCV? Thanks in advance. EDITED: Here is the code I'm using: Mat img_object = imread(patternImageName); Mat a; for (int index = 0,j = 0; index < img_object.rows; index = index + 2, j++) { a.row(j) = img_object.row(index); } But it throws the following exception: OpenCV Error: Assertion failed (m.dims >= 2) in Mat, file

Assertion failed in Mat OpenCV

微笑、不失礼 提交于 2019-12-11 19:48:30
问题 I am running the EM algorithm in OpenCV several times in a loop. Initially the EM runs with default initial parameters. In subsequent iterations we pass parameters to the EM algorithm based on output of previous iteration. Here is the code Mat meansCombine; Mat weightsCombine; vector<Mat> covsCombine; for(int k=maxComponents; k>=minComponents; k--){ EM model(k,EM::COV_MAT_DIAGONAL,TermCriteria(TermCriteria::COUNT+TermCriteria::EPS,2,0.0001)); Mat labels; Mat probs; Mat log_likelihoods; if( k=

converting Mat to iplimage* in opencv

≯℡__Kan透↙ 提交于 2019-12-11 16:22:29
问题 I am new in opencv and c++. what is the difference between iplimage and iplimage*? I used cvHaarDetectObjects that need iplimage* in arg[1]. I have a frame in the format of Mat. how could I convert Mt to iplimage*? (I found a way to convert mat to iplimage but not to iplimage*). the true one is : iplimage* frame=cvLoadImage("1.jpg"); objects = cvHaarDetectObjects( frame, face_cascade, storage, scale_factor, 1 ); but I want to use: Mat frame; //some functions are performed on frame objects =

saving and loading vector<Mat> Qt & OpenCV

假装没事ソ 提交于 2019-12-11 14:04:07
问题 I'm working on face recognition in Qt & openCV using the FisherFaces recognizer which doesn't support updating so i have to save the faces database to retrain the recognizer after any changes. Here is my code for saving : save(const std::vector* MatVect){ QFile file("students_dataset.dat"); file.open(QIODevice::WriteOnly); QDataStream out(&file); QVector qimgvect; for (size_t i = 0; i < MatVect->size(); ++i) { cv::Mat matt = MatVect->at(i); QImage img((uchar*)matt.data, matt.cols, matt.rows,

Avoiding memory leaks while using vector<Mat>

二次信任 提交于 2019-12-11 11:55:28
问题 I am trying to write a code that uses opencv Mat objects it goes something like this Mat img; vector<Mat> images; for (i = 1; i < 5; i++) { img.create(h,w,type) // h,w and type are given correctly // input an image from somewhere to img correctly. images.push_back(img); img.release() } for (i = 1; i < 5; i++) images[i].release(); I however still seem to have memory leakage can anyone tell me why it is so? I thought that if the refcount of a mat object = 0 then the memory should be