Ask Your Question

Revision history [back]

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?

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.