Ask Your Question

MattM's profile - activity

2014-02-04 09:21:52 -0600 received badge  Supporter (source)
2014-02-04 09:09:39 -0600 commented answer Returning a Mat from native JNI to Java

Can you expand on this? I'm facing the same issue as the poster but I'm having trouble with the implementation.

I understand things on the java side. The first line in C++ makes sense. The second line corresponds to making the image (in my example case im loading it from a file with imread, long term ill get the data delivered over Ethernet, read in C++, altered by openCV in C++ then passed to java for display in a GUI).

The third line I don't understand at all. What is the second argument of memcpy?

Here is my C++ code:

void getCVMat(long matPtr) { cv::Mat * image; image = new cv::Mat(); image = (cv::Mat*) matPtr;

std::string filepath = "C:\\temp\\java.jpg";
(*image) = cv::imread(filepath);

}

This is functional, until its integrated with the main GUI where it crashed the JVM.