mat

Pass and return OpenCv Mat object with JNI

大憨熊 提交于 2019-12-20 06:32:39
问题 I would like to write a function in JNI like this: JNIEXPORT jobject JNICALL Java_com_datumdroid_android_ocr_simple_HoughLine_nativeDetectLine (JNIEnv * jenv, jclass, jstring fileInput, jobject mat) The Java interface would be : nativeDetectLine( String fileInput, Mat mat); Now I want to pass the Mat to JNI and change its value. Can anyone give me a tutorial or guide? Specifically how work with jobjects. 回答1: http://answers.opencv.org/question/12271/can-the-java-interface-pass-a-mat-to

OpenCV Mat array access, which way is the fastest for and why?

。_饼干妹妹 提交于 2019-12-19 08:14:35
问题 I am wondering about the way of accessing data in Mat in OpenCV. As you know, we can access to get data in many ways. I want to store image (Width x Height x 1-depth) in Mat and looping access each pixel in the image. Using ptr<>(irow) to get row-pixel and then access each column in the row is the best way? or using at<>(irow,jcol) is the best? or using directly calculate the index by using index = irow*Width + jrow is the best? Anyone know the reason. Thanks in advance 回答1: You can find

outOfMemoryError with background drawables

这一生的挚爱 提交于 2019-12-19 04:14:44
问题 I read a lot about memory leaks with Bitmaps but I can't solve my problem. I have an app works fine in my phone, but in others I'm getting the outOfMemoryError bitmap size exceeds VM. My problem is that I don't understand how to free this resources. I have a game with several activities and dialog with drawables in background in XML files, sometimes as a layout background and sometimes as a ImageView to fullscreen. How I can free this memory? I can't use recycle, I'm use unbindDrawables

How to convert a heap dump in android to eclipse format

半世苍凉 提交于 2019-12-18 11:29:08
问题 Im attempting to analyze a memory leak that has been driving me crazy for weeks, I found out about the eclipse MAT tool that helps you to figure out what is wrong, the problem is every single tutorial I have found says that I need to convert the format of the file from dalvik to HPROF format, however not one single tutorial I can find explains how to actually do it, instead I get vague things like this Now the file you will get does not conform to the "standard" Sun .hprof format but is

Convert FreeImage FIBITMAP format to OpenCV Mat

梦想与她 提交于 2019-12-18 07:23:19
问题 I've been searching on an answer but all I can find is the inverse of what I need (Mat to FIBITMAP). I have a short code that loads images as FIBITMAP objects. I need FreeImage because OpenCV doesn't allow me to load pfm and some other extension files. What I'm trying to do is convert the FIBTMAP image into an OpenCV Mat so that I can use this in a much longer code I already have. How do I do? 回答1: The funtion FI2MAT will perform the conversion from FreeImage to OpenCV Mat. I cannot

Bitmap to Mat gives wrong colors back

北城余情 提交于 2019-12-18 05:09:29
问题 So I make a bitmap from a blob with the next code: byte[] blob = contact.getMP(); ByteArrayInputStream inputStream = new ByteArrayInputStream(blob); Bitmap bitmap = BitmapFactory.decodeStream(inputStream); Bitmap scalen = Bitmap.createScaledBitmap(bitmap, 320, 240, false); and it gives back the next output, which is good Then I do the following to make the bitmap into a Mat, but then my colors just change... //Mat ImageMat = new Mat(); Mat ImageMat = new Mat(320, 240, CvType.CV_32F); Utils

convert Bitmap to Mat after capture image using android camera

被刻印的时光 ゝ 提交于 2019-12-17 17:29:57
问题 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)

How to write a Float Mat to a file in OpenCV

廉价感情. 提交于 2019-12-17 09:35:23
问题 I have a matrix Mat B(480,640,CV_32FC1); containing floating values..I want to write this matrix to a file which could be opened in notepad or Ms word or Excel to see the values inside and for storage....imwrite function can save 8-bit or 16-bit image only.. Drop in your suggestions if this could be done?? if yes, how ?? 回答1: Using pure OpenCV API calls: // Declare what you need cv::FileStorage file("some_name.ext", cv::FileStorage::WRITE); cv::Mat someMatrixOfAnyType; // Write to file! file

C++ OpenCV image sending through socket

南楼画角 提交于 2019-12-17 08:53:38
问题 I'm trying to implement a streaming service using OpenCV and sockets. The server side loads a given image and sends it to the client, which receives it through the socket and displays it. I'm having a lot of trouble, though, sending the data of the image and reconstructing it on the client side. This is the code I've made so far: Image sender: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h>

Converting BufferedImage to Mat in opencv

本小妞迷上赌 提交于 2019-12-17 06:39:08
问题 How can I convert a BufferedImage to a Mat in OpenCV? Im using the java wrapper for OpenCV(not JavaCV). As I am new to OpenCV I have some problems understanding how Mat works. I want to do something like this. (Based on Ted W. reply): BufferedImage image = ImageIO.read(b.getClass().getResource("Lena.png")); int rows = image.getWidth(); int cols = image.getHeight(); int type = CvType.CV_16UC1; Mat newMat = new Mat(rows,cols,type); for(int r=0; r<rows; r++){ for(int c=0; c<cols; c++){ newMat