mat

What is the difference between UMat and Mat in OpenCV?

≯℡__Kan透↙ 提交于 2019-11-28 09:41:09
I have been through the documentation and didn't get a clear detailed description about UMat; however I think it has something to relate with GPU and CPU. Please help me out. Thank you. Perhaps section 3 of this document will help: [link now broken] https://software.intel.com/sites/default/files/managed/2f/19/inde_opencv_3.0_arch_guide.pdf Specifically, section 3.1: A unified abstraction cv::UMat that enables the same APIs to be implemented using CPU or OpenCL code, without a requirement to call OpenCL accelerated version explicitly. These functions use an OpenCL-enabled GPU if exists in the

Acces Matrix value without knowing the type opencv

独自空忆成欢 提交于 2019-11-28 09:18:31
问题 I am writing a function in which I need to access to a element of a Mat , but this function can receive Mat of differents types. So, if I have: filtered.at<TypeofMat>(i) = (typeofmat) somevalue; It only occurs to me to do something like this filtered.at<myMat.type()>(i) , but obviously this does not work because type returns a int I am stuck, Could someone give some light? 回答1: You can convert the source matrix to a matrix of double (type CV_64F ). In this way you won't lose any data due to

How do i get the size of a multi-dimensional cv::Mat? (Mat, or MatND)

和自甴很熟 提交于 2019-11-28 05:58:31
I am creating a multi-dimensional MAT object, and would like to get the size of the object - e.g., const int sz[] = {10,10,9}; Mat temp(3,sz,CV_64F); std::cout << "temp.dims = " << temp.dims << " temp.size = " << temp.size() << " temp.channels = " << temp.channels() << std::endl; I believe the resulting MAT to be 10x10x9, and I'd like to confirm, but the COUT statement gives: temp.dims = 3 temp.size = [10 x 10] temp.channels = 1 I was hoping to see either: temp.dims = 3 temp.size = [10 x 10 x 9] temp.channels = 1 Or: temp.dims = 3 temp.size = [10 x 10] temp.channels = 9 How can I get the

convert Bitmap to Mat after capture image using android camera

隐身守侯 提交于 2019-11-28 03:50:32
Mat b = new Mat(); Bitmap bmp = getIntent().getExtras().getParcelable("image_send"); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_display_image); Mat tmp = new Mat (bmp.getWidth(), bmp.getHeight(), CvType.CV_8UC1); Utils.bitmapToMat(bmp, tmp); Imgproc.cvtColor(tmp, tmp, Imgproc.COLOR_RGB2GRAY); //Imgproc.cvtColor(tmp, tmp, Imgproc.COLOR_GRAY2RGB, 4); Utils.matToBitmap(tmp, bmp); iv = (ImageView) findViewById(R.id.imageView1); iv.setImageBitmap(bmp); } Can't display the bmp. My app has stopped after taking a

OpenCV cv::Mat set if

混江龙づ霸主 提交于 2019-11-28 03:21:31
问题 Is there a simple way to set all values in a cv::Mat to a given value if they fulfill some condition. For instance, I have CV_32FC1, and I want set all values which are 0 to 20. In MATLAB I would have simply done this: M(M == 0) = 20; 回答1: You can use cv::Mat mask = M == 0; M.setTo(0.5, mask); However, it includes using additional memory for creating mask, but is a solution using opencv API therefore can be applied to all matrix types. If you consider performance issues, you can always refer

How can I get and set pixel values of an EmguCV Mat image?

僤鯓⒐⒋嵵緔 提交于 2019-11-28 01:52:58
I'm using the EmguCV 3.0.0 wrapper to the OpenCV 3.0 library. I'm using the Mat class in a few places. Here's an example of a single channel, 8x8 image made of double values: Mat image = new Mat(8, 8, DepthType.Cv64F, 1); The Image<> class provides reasonable means for getting and setting pixel values , and the method is identical for the Matrix<> class, but it doesn't seem as obvious for the Mat class. The only way I've figured out how to set individual pixel is using a mask: // set two pixel values, (0,0) to 9.0, (2, 3) to 42.0 Matrix<byte> mask = new Matrix<byte>(8,8); mask.Data[0, 0] = 1;

Get frame from video with libvlc smem and convert it to opencv Mat. (c++)

梦想与她 提交于 2019-11-27 23:12:32
[UPDATED WITH PARTIAL ANSWER] Here is my code: void cbVideoPrerender(void *p_video_data, uint8_t **pp_pixel_buffer, int size) { // Locking imageMutex.lock(); videoBuffer = (uint8_t *)malloc(size); *pp_pixel_buffer = videoBuffer; } void cbVideoPostrender(void *p_video_data, uint8_t *p_pixel_buffer , int width, int height, int pixel_pitch, int size, int64_t pts) { // Unlocking imageMutex.unlock(); Mat img = Mat(Size(width,height), CV_8UC3, p_pixel_buffer); //cvtColor(img,img,CV_RGB2BGR); } int main(int argc, char ** argv) { libvlc_instance_t * inst; char smem_options[1000]; sprintf(smem_options

Conversion from IplImage* to cv::MAT

邮差的信 提交于 2019-11-27 18:49:44
I searched to convert an IplImage* to Mat, but all answers were about the conversion to cvMat. How, can I do it? and what is the difference between Mat and cvMat? Thanks in advance here is a good solution Mat(const IplImage* img, bool copyData=false); For the records: taking a look at core/src/matrix.cpp it seems that, indeed, the constructor cv::Mat(IplImage*) has disappeared. But I found this alternative: IplImage * ipl = ...; cv::Mat m = cv::cvarrToMat(ipl); // default additional arguments: don't copy data. The recommended way is the cv::cvarrToMat function cv::Mat - is base data structure

Convert a string of bytes to cv::mat

坚强是说给别人听的谎言 提交于 2019-11-27 18:25:55
问题 I need to implement a function that receives a string containing the bytes of an image (received via boost socket connection) and converts the info into an OpenCV cv::Mat . I also know the width and height of the image and its size in bytes. My function looks like this: void createImageFromBytes(const std::string& name, std::pair<int,int> dimensions, const std::string& data) { int width,height; width = dimensions.first; height = dimensions.second; //convert data to cv::Mat image std::string

UnsatisfiedLinkError: n_Mat while using opencv2.4.3 with android 4.0

走远了吗. 提交于 2019-11-27 15:09:39
问题 i am using opencv in android. but when i am adding Mat() in my code my application unexpectedly stops after launch. my error log is as below: FATAL EXCEPTION: main java.lang.UnsatisfiedLinkError: n_Mat at org.opencv.core.Mat.n_Mat(Native Method) at org.opencv.core.Mat.<init>(Mat.java:441) at com.example.imagepro.MainActivity.onCreate(MainActivity.java:36) at android.app.Activity.performCreate(Activity.java:4465) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049) at