mat

OpenCv create 3 channel Mat from continuous data array

老子叫甜甜 提交于 2020-07-06 11:27:10
问题 I'd like to create an OpenCV 3-channel Mat using data allocated elsewhere where the pixels of each channel are together, unlike the data for an OpenCV Mat where the data from different channels is interleaved. Mat outputMat = Mat(dimY, dimX, CV_8UC3, rawData); // This works only if rawData interleaves channel data like an OpenCv Mat Is there a way to create an OpenCV Mat without having to resort to the below solution of splitting channels from a temporary Mat and copying the right channel

Reading values in opencv_face.LBPHFaceRecognizer.getHistograms()

坚强是说给别人听的谎言 提交于 2020-06-23 13:22:23
问题 I am trying to work with the open_cv library in android. I have never worked on it before, so this may be a very basic question. I have an opencv_face.LBPHFaceRecognizer object in my Recognizer Activity. My requirement is to read the histogram values for previously-stored faces. opencv_face.LBPHFaceRecognizer mFaceRecognizer = = createLBPHFaceRecognizer(2, 8, 8, 8, 95); File file = new File(RegisterActivity.getFilePath(mContext)); mFaceRecognizer.load(file.getAbsolutePath()); opencv_core

How can convert PyObject variable to Mat in c++ opencv code

跟風遠走 提交于 2020-05-01 09:16:52
问题 I have a c++ facerecognition code and a python code in opencv. In python code i read frames from a robot and i want to send this fram to my c++ code. I use this link tho call python function in c++ function. my c++ function is embed.cpp: #include <Python.h> #include <stdlib.h> #include "opencv2/core/core.hpp" #include "opencv2/contrib/contrib.hpp" #include "opencv2/highgui/highgui.hpp" #include <iostream> #include <fstream> #include <sstream> #include </home/nao/Desktop/python/boost_1_61_0

How can convert PyObject variable to Mat in c++ opencv code

假装没事ソ 提交于 2020-05-01 09:15:27
问题 I have a c++ facerecognition code and a python code in opencv. In python code i read frames from a robot and i want to send this fram to my c++ code. I use this link tho call python function in c++ function. my c++ function is embed.cpp: #include <Python.h> #include <stdlib.h> #include "opencv2/core/core.hpp" #include "opencv2/contrib/contrib.hpp" #include "opencv2/highgui/highgui.hpp" #include <iostream> #include <fstream> #include <sstream> #include </home/nao/Desktop/python/boost_1_61_0

Android内存泄漏-MAT篇

拥有回忆 提交于 2020-04-27 06:25:33
最近项目中的内存越来越大,于是了解关于Android内存分析相关的知识,用以解决实际问题。现在有很多好的内存分析工具比如: LeakCanary、DDMS、mat。 一、首先简单介绍下LeakCanary: 在build.gradle文件中添加  在应用的application onCreate方法中添加LeakCanary.install(this),如下  应用运行起来后,LeakCanary会自动去分析当前的内存状态,如果检测到泄漏会发送到通知栏,点击通知栏就可以跳转到具体的泄漏分析页面。 二、下面重点介绍下DDMS结合mat分析内存泄漏问题。 使用mat分析首先要通过eclipse或是Android studio生成hprof文件,然后使用命令cd到Android sdk的目录下: cd /usr/local/android/sdk/tools //改成自己的sdk目录 hprof-conv com.scics.huaxi.hprof ff.hprof //转换格式命令 这样就生成可供mat分析的hprof文件。http://www.eclipse.org/mat/ 此处可下载mat,可以下载独立版亦可以下载eclipse插件版,本人下的是独立版本。将我们得到的hprof文件导入mat中得如下结果: 深色区域的3.6MB、9.3MB、9.6MB标示有内存泄漏的

OpenCV 3D Mat to Vector

二次信任 提交于 2020-01-24 12:53:52
问题 I have 3D Mat and would like to convert it to Vector. I tried opencv's reshape() function but it seems to not work with matrices that have dimensions more than 2. How can I convert to 3D Mat to Vector ? I can do it by accessing all elements in the Mat. Is there any efficient way? 回答1: If we have the following 3D matrix: const int ROWS=2, COLS=3, PLANES=4; int dims[3] = {ROWS, COLS, PLANES}; cv::Mat m = cv::Mat(3, dims, CV_32SC1); // works with other types (e.g. float, double,...) This only

Memory leak with Mat in convertTo-function

可紊 提交于 2020-01-21 20:05:38
问题 I have some trouble with managing memory in my function. Valgrid says I'm having a memory leak after the convert-function. Could it be because of the data is not being properly released? I've tried to use temp-pointers, but my program either crashes or is not working properly. Have someone encountered this problem before? this->images.push_back(new cv::Mat()); //ID cv::threshold(*this->images[MASK], *this->images[ID], 0.0, 1.0, cv::THRESH_BINARY); this->images[ID]->convertTo(*this->images[ID]

Convert Mat to Blob and then back to Mat

痴心易碎 提交于 2020-01-14 03:28:08
问题 Basically I am trying facial recognition using OpenCV Android. I need to convert a Mat image that is received during face detection via inputFrame.gray(); in CvCameraViewFrame into a blob that is a byte[] to save into an SQLite database. Then, during recognition, convert this byte[] back to a Mat file that can be used in .cpp files in the jni folder, as recognition code is native. 回答1: [edit] it turned out to be quite easy with androids onboard methods: import org.opencv.core.Mat; import

Java 内存分析 MAT 工具

强颜欢笑 提交于 2020-01-09 10:15:57
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> Eclipse Memory Analyzer (MAT) This article describes the usage of the Eclipse Memory Analyzer (MAT) to identify memory leaks. This article is based on Eclipse 4.5. 1. Memory handling in Java Java handles its memory in two areas. The heap and the stack . We will start with a short overview of memory in general on a computer. Then the Java heap and stack is explained. 1.1. Native Memory() Native memory is the memory which is available to a process, e.g. the Java process. Native memory is controlled by the operating system (OS) and based on physical memory and

OpenCV copyTo assert error

青春壹個敷衍的年華 提交于 2020-01-06 03:26:12
问题 While copying one Mat into the region of interest of another I came accross an error I've never seen before. Googling it didn't turn up many results and none of them seems to be relevant. I have included a screenshot of the error as well as some properties of the Mat's. This is the code: std::cout << "size height,width: " << size.height << ", " << size.width << std::endl; cv::Mat tempResult(size.width, size.height, result.type()); std::cout << "tempResult cols,rows: " << tempResult.cols << ",