I'm very new at C++ and I'm trying to create a DLL
which uses OpenCV library.
My DLL
gets a raw image from other application and creates a MAT
from the application's memory buffer. I send the buffer's address, which has a raw image, to the DLL
and get raw image to OpenCV. This part works.
But after processing image with OpenCV, I can't write raw image to same memory address.
This is the code snippet that I've tried:
fn_export double createImage(char* address double width, double height) {
unsigned char* pBuffer = (unsigned char*)address;
memcpy(&pBuffer,&address, sizeof(pBuffer));
cv::Mat img = cv::Mat(height,width, CV_8UC4, pBuffer);
cv::imshow("Original", img);
memcpy(&address, &img.data[0], sizeof(address));
return 1;
}
char* address
is memory address from my application. Other application's buffer doesn't change this way. Anybody has any advice about this situation?