cv::Mat pass by Reference to other share lib
Hi All, I am a new comer in OpenCV and currently using OpenCV2.4.8. I got 2 source file which one is the main and the other is a complied as a share lib which call by the main.cpp.
When i try to print the frame.depth() in the main after getting the frame from web cam , it return 0 ( which should be CV_8U ), however , when i pass it to the share lib , it return 1 on the depth() call. I haven't change anything on the Mat , could any one help to explain why the depth and type is changed after passed to the lib and am i passing the reference incorrectly ?
Thanks in advance.
Dick
Here is the source code for Main.cpp
using namespace cv;
void onMouse(int event, int x ,int y, int flags,void* param);
int main(int argc,char** argv){
VideoCapture cap(-1);
Mat frame;
Mat grey;
double width;
double height;
namedWindow("WebCam",1);
cvSetMouseCallback("WebCam",onMouse,NULL);
width = cap.get(CV_CAP_PROP_FRAME_WIDTH);
height = cap.get(CV_CAP_PROP_FRAME_HEIGHT);
grey = Mat(height,width,CV_8UC1);
while(1){
cap >> frame;
printf("frame.depth %d\n",frame.depth()); // it will return 0;
printf("frame.type %d\n",frame.type()); // it will return 16;
preprocessing(frame,grey); // pass to share lib
imshow("WebCam",grey);
if(cvWaitKey(1)>=0){
break;
}
}
cvDestroyWindow("WebCam");
return 0;
}
Here is the Source for preprocess.cpp , it is complied to libpreprocess.so
void preprocessing(const Mat &imgSrc,Mat &resultImg)
{
printf("imgSrc.depth %d\n",imgSrc.depth()); // here, it will return 1;
printf("imgSrc.type %d\n",imgSrc.type()); // here it will return 1;
}