matrices as function arguments
I'm dealing with c and cpp files in my project. I've some data in matrix form in .cpp file now and I want to use this matrix data in .c file. As .c files don't use matrices but only .cpp files use... so, matrices can't be passed accross functions in this case.
How should I deal with such situation in openCV?
Example:
I've the following function in .cpp file.
extern "C"
{
unsigned char *img_four_regions(unsigned char *img1);
}
unsigned char *img_four_regions(unsigned char *img1)
{
unsigned char *top_left;
top_left = img1;
cv::Mat TempMat = cv::Mat(138, 640, CV_8UC1, top_left);
Mat temp_top_right;
Mat temp_top_left;
Mat temp_bottom_right;
Mat temp_bottom_left;
TempMat(Range(0, 69), Range(0, 320)).copyTo(temp_top_right);
imshow("top right", temp_top_right);
waitKey(0);
TempMat(Range(0, 69), Range(321, 640)).copyTo(temp_top_left);
imshow("top right", temp_top_left);
waitKey(0);
TempMat(Range(70, 138), Range(0, 320)).copyTo(temp_bottom_right);
imshow("top right", temp_bottom_right);
waitKey(0);
TempMat(Range(70, 138), Range(321, 640)).copyTo(temp_bottom_left);
imshow("top right", temp_bottom_left);
waitKey(0);
Now I want to use the matrices named "temp_bottom_right, temp_bottom_left, temp_top_right, temp_top_left" in .c file by calling this function.
sorry, but atm. this is too broad. can you specify your exact needs, and give an example ?
please check the edited question now.
You can't use the cv::Mat object, but you can access the memory if you want.
To do that, have four output pointers each pointing to the amount of memory needed for that section. Then construct temp_top_right and the others like you did TempMat and do the copyTo just like you do. Now those pointers contain just the quarter of the image.
your current "C" concept has some flaws:
non-continuous mats meaning?
?????????????
like a roi, think of this: