High-quality-ellipse-detection icon indicating copy to clipboard operation
High-quality-ellipse-detection copied to clipboard

Error mex the file

Open trinity-shuxianfan opened this issue 5 years ago • 24 comments

Error using mex Undefined symbols for architecture x86_64: "cv::Mat::deallocate()", referenced from: cvCanny3(void const*, void*, void*, void*, int) in generateEllipseCandidates.o Canny3(cv::InputArray const&, cv::OutputArray const&, cv::OutputArray const&, cv::OutputArray const&, int, bool) in generateEllipseCandidates.o calculateGradient3(double*, unsigned int, unsigned int, image_double_s**) in generateEllipseCandidates.o mexFunction in generateEllipseCandidates.o cv::MatExpr::~MatExpr() in generateEllipseCandidates.o "cv::Mat::zeros(int, int, int)", referenced from: calculateGradient3(double*, unsigned int, unsigned int, image_double_s**) in generateEllipseCandidates.o mexFunction in generateEllipseCandidates.o "cv::Mat::create(int, int const*, int)", referenced from: cvCanny3(void const*, void*, void*, void*, int) in generateEllipseCandidates.o "cv::Mat::operator=(cv::Scalar const&)", referenced from: cvCanny3(void const*, void*, void*, void*, int) in generateEllipseCandidates.o "cv::line(cv::Mat&, cv::Point, cv::Point, cv::Scalar const&, int, int, int)", referenced from: mexFunction in generateEllipseCandidates.o "cv::error(cv::Exception const&)", referenced from: cvCanny3(void const*, void*, void*, void*, int) in generateEllipseCandidates.o "cv::ellipse(cv::Mat&, cv::Point, cv::Size, double, double, double, cv::Scalar const&, int, int, int)", referenced from: _mexFunction in generateEllipseCandidates.o "cv::fastFree(void*)", referenced from: cvCanny3(void const*, void*, void*, void*, int) in generateEllipseCandidates.o Canny3(cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, int, bool) in generateEllipseCandidates.o calculateGradient3(double*, unsigned int, unsigned int, image_double_s**) in generateEllipseCandidates.o _mexFunction in generateEllipseCandidates.o cv::MatExpr::~MatExpr() in generateEllipseCandidates.o "cv::Exception::Exception(int, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, int)", referenced from: cvCanny3(void const*, void*, void*, void*, int) in generateEllipseCandidates.o "cv::Exception::~Exception()", referenced from: cvCanny3(void const*, void*, void*, void*, int) in generateEllipseCandidates.o "vtable for cv::_InputArray", referenced from: calculateGradient3(double*, unsigned int, unsigned int, image_double_s**) in generateEllipseCandidates.o NOTE: a missing vtable usually means the first non-inline virtual member function has no definition. "vtable for cv::_OutputArray", referenced from: calculateGradient3(double*, unsigned int, unsigned int, image_double_s**) in generateEllipseCandidates.o NOTE: a missing vtable usually means the first non-inline virtual member function has no definition. "_cvGetMat", referenced from: cvCanny3(void const*, void*, void*, void*, int) in generateEllipseCandidates.o "_cvSobel", referenced from: cvCanny3(void const*, void*, void*, void*, int) in generateEllipseCandidates.o "dggev", referenced from: fitEllipse(point2d*, int, double*) in generateEllipseCandidates.o fitEllipse2(double*, double*) in generateEllipseCandidates.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

trinity-shuxianfan avatar Jan 07 '20 01:01 trinity-shuxianfan

Error using mex Undefined symbols for architecture x86_64: "cv::Mat::deallocate()", referenced from: cvCanny3(void const*, void*, void*, void*, int) in generateEllipseCandidates.o Canny3(cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, cv::OutputArray const&, int, bool) in generateEllipseCandidates.o calculateGradient3(double*, unsigned int, unsigned int, image_double_s**) in generateEllipseCandidates.o mexFunction in generateEllipseCandidates.o cv::MatExpr::~MatExpr() in generateEllipseCandidates.o "cv::Mat::zeros(int, int, int)", referenced from: calculateGradient3(double*, unsigned int, unsigned int, image_double_s**) in generateEllipseCandidates.o mexFunction in generateEllipseCandidates.o "cv::Mat::create(int, int const*, int)", referenced from: cvCanny3(void const*, void*, void*, void*, int) in generateEllipseCandidates.o "cv::Mat::operator=(cv::Scalar const&)", referenced from: cvCanny3(void const*, void*, void*, void*, int) in generateEllipseCandidates.o "cv::line(cv::Mat&, cv::Point, cv::Point, cv::Scalar const&, int, int, int)", referenced from: mexFunction in generateEllipseCandidates.o "cv::error(cv::Exception const&)", referenced from: cvCanny3(void const*, void*, void*, void*, int) in generateEllipseCandidates.o "cv::ellipse(cv::Mat&, cv::Point, cv::Size, double, double, double, cv::Scalar const&, int, int, int)", referenced from: _mexFunction in generateEllipseCandidates.o "cv::fastFree(void*)", referenced from: cvCanny3(void const*, void*, void*, void*, int) in generateEllipseCandidates.o Canny3(cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, int, bool) in generateEllipseCandidates.o calculateGradient3(double*, unsigned int, unsigned int, image_double_s**) in generateEllipseCandidates.o _mexFunction in generateEllipseCandidates.o cv::MatExpr::~MatExpr() in generateEllipseCandidates.o "cv::Exception::Exception(int, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, int)", referenced from: cvCanny3(void const*, void*, void*, void*, int) in generateEllipseCandidates.o "cv::Exception::~Exception()", referenced from: cvCanny3(void const*, void*, void*, void*, int) in generateEllipseCandidates.o "vtable for cv::_InputArray", referenced from: calculateGradient3(double*, unsigned int, unsigned int, image_double_s**) in generateEllipseCandidates.o NOTE: a missing vtable usually means the first non-inline virtual member function has no definition. "vtable for cv::OutputArray", referenced from: calculateGradient3(double*, unsigned int, unsigned int, image_double_s**) in generateEllipseCandidates.o NOTE: a missing vtable usually means the first non-inline virtual member function has no definition. "cvGetMat", referenced from: cvCanny3(void const*, void*, void*, void*, int) in generateEllipseCandidates.o "cvSobel", referenced from: cvCanny3(void const*, void*, void*, void*, int) in generateEllipseCandidates.o "dggev", referenced from: fitEllipse(point2d*, int, double*) in generateEllipseCandidates.o fitEllipse2(double*, double*) in generateEllipseCandidates.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

you didn't write link flag....

xiahaa avatar May 20 '20 15:05 xiahaa

@xiahaa So how to link flag? When I mex the file, some errors like: undefined reference to `cv::Exception::Exception(int, std::string const&, std::string const&, std::string const&, int)'

real-lixin avatar Aug 17 '20 05:08 real-lixin

@xiahaa So how to link flag? When I mex the file, some errors like: undefined reference to `cv::Exception::Exception(int, std::string const&, std::string const&, std::string const&, int)'

mex -L/path_to_your_lib -lxxxx

xiahaa avatar Aug 17 '20 07:08 xiahaa

@xiahaa But the error persist: C:\Users\AppData\Local\Temp\mex_93217854689248_9244\generateEllipseCandidates.obj:generateEllipseCandidates.cpp:(.text+0x8e67): undefined reference to `cv::Exception::Exception(int, std::string const&, std::string const&, std::string const&, int)'

real-lixin avatar Aug 17 '20 08:08 real-lixin

@xiahaa But the error persist: C:\Users\AppData\Local\Temp\mex_93217854689248_9244\generateEllipseCandidates.obj:generateEllipseCandidates.cpp:(.text+0x8e67): undefined reference to `cv::Exception::Exception(int, std::string const&, std::string const&, std::string const&, int)'

this is not a link error. try add mex xxxx -v to enable verbose. And then show the detailed error. I remember that there is another error you need to fix.

xiahaa avatar Aug 17 '20 08:08 xiahaa

@xiahaa Thank you. When I use mex xxx -v, it gives detailed information like that"MinGW64 Compiler (C++), xxx." Here I all the error messages, could you analyze them for me?

real-lixin avatar Aug 17 '20 08:08 real-lixin

@xiahaa I use the mex command in matlab like this: mex generateEllipseCandidates.cpp -v... '-ID:\Program Files\opencv_2.4.9\build\include'... '-ID:\Program Files\opencv_2.4.9\build\include\opencv'... '-ID:\Program Files\opencv_2.4.9\build\include\opencv2'... '-LD:\Program Files\opencv_2.4.9\build\x64\vc11\lib'... '-ID:\Program Files\MATLAB\R2017a\extern\include'... '-LD:\Program Files\MATLAB\R2017a\extern\lib\win64\microsoft'... -lopencv_core249... -lopencv_highgui249... -lopencv_imgproc249... -llibmwlapack.lib

real-lixin avatar Aug 17 '20 08:08 real-lixin

if you open D:\Program Files\opencv_2.4.9\build\x64\vc11\lib can u see opencv_core249.lib, etc?

xiahaa avatar Aug 17 '20 08:08 xiahaa

if you open D:\Program Files\opencv_2.4.9\build\x64\vc11\lib can u see opencv_core249.lib, etc?

Yes, the file "opencv_core249.lib" is in the right folder.

real-lixin avatar Aug 17 '20 08:08 real-lixin

try uncomment the following code, and make a visual studio project using this pure c++ code (no mex functions are used). Once you have successfully compiled the code and run without error in visual studio. then I think u can mex compile the code.

// int main(int argc, const char * argv[]) { // // insert code here... // printf("Hello, World!\n");

// std::string images_folder = "/Volumes/document/fore-end/ellipse_detection/thirdparty/detection/High-quality-ellipse-detection-master/pics"; // // "/Volumes/document/fore-end/ellipse_detection/data/test_data"; // std::string out_folder = images_folder; // std::vectorstd::string names; // names.push_back(images_folder+"/"+"27.jpg"); // //glob(images_folder + "Lo3my4.*", names);

// for (const auto& image_name : names) // { // std::string name = image_name.substr(image_name.find_last_of("/") + 1); // name = name.substr(0, name.find_last_of("."));

// Mat3b image = imread(image_name); // Size sz = image.size();

// // Convert to grayscale // Mat1b gray;//1b is one byte // cvtColor(image, gray, CV_BGR2GRAY);

// int edge_process_select = 2; // int specified_polarity = 0;

// int imgy = gray.rows; // int imgx = gray.cols;

// uchar ptr = (uchar)gray.data;

// double data=(double)malloc(imgyimgxsizeof(double));//????????????????????????????????????????????????????????? // for(int c=0;c<imgx;c++) // { // for(int r=0;r<imgy;r++) // { // data[c+rimgx]=ptr[c+rimgx]; // } // }

// int n;//???????????? // //int new_n; // std::vector<std::vector> groups; // double * coverages; // int * reg; // int reg_x; // int reg_y; // double* out=mylsd(&n, data,imgx,imgy,&reg,&reg_x,&reg_y); // groupLSs(out,n,reg,reg_x,reg_y,&groups);//????????? done. // free(reg); //???????????? // calcuGroupCoverage(out,n,groups,coverages);//??????????????????????????????, done

// printf("The number of output arc-support line segments: %i\n",n); // printf("The number of arc-support groups:%i\n",groups.size());

// image_double angles; // if(edge_process_select == 1) // calculateGradient2(data,imgx,imgy,&angles); //version2, sobel; version 3 canny // else // calculateGradient3(data,imgx,imgy,&angles); //version2, sobel; version 3 canny // PairGroupList * pairGroupList; // double distance_tolerance = 2;//max( 2.0, 0.005*min(angles->xsize,angles->ysize) ); // 0.005%*min(xsize,ysize) // double * candidates; //???????????? // double * candidates_out;//???????????????????????? // int candidates_num = 0;//?????????????????? // //rejectShortLines(out,n,&new_n); // pairGroupList = getValidInitialEllipseSet(out,n,&groups,coverages,angles,distance_tolerance,specified_polarity); // // double *candidates_out = NULL; // if(pairGroupList != NULL) // { // printf("The number of initial ellipses???%i \n",pairGroupList->length); // generateEllipseCandidates(pairGroupList, distance_tolerance, candidates, &candidates_num); // printf("The number of ellipse candidates: %i \n",candidates_num);

// // plhs[0] = mxCreateDoubleMatrix(5,candidates_num,mxREAL); // // candidates_out = (double*)mxGetPr(plhs[0]); // candidates_out = (double *)malloc(sizeof(double)5candidates_num); // if (candidates_out == NULL) // { // std::cout << "initialize candidates_out failed!"<<std::endl; // assert(1); // } // //???????????????(xi,yi,ai,bi,phi_i)', 5 x candidates_num, ???????????????candidates_out??? // memcpy(candidates_out,candidates,sizeof(double)5candidates_num);

// freePairGroupList(pairGroupList); // free(candidates); // } // else // { // printf("The number of initial ellipses???%i \n",0); // // double candidates_out; // // plhs[0] = mxCreateDoubleMatrix(5,1,mxREAL); // // candidates_out = (double)mxGetPr(plhs[0]); // // candidates_out[0] = candidates_out[1] = candidates_out[2] = candidates_out[3] = candidates_out[4] = 0; // } // // uchar edgeimg_out; // unsigned long edge_pixels_total_num = 0;//??????????????? // double gradient_vec_out; // // plhs[1] = mxCreateNumericMatrix(imgy,imgx,mxUINT8_CLASS,mxREAL); // // edgeimg_out = (uchar)mxGetData(plhs[1]); // //???????????????????????????edgeimg_out??? // //???????????????????????????gradient_vec_out??? // cv::Mat edgeimg_out(imgy,imgx,CV_8UC1); // unsigned long addr,g_cnt = 0; // for ( int c = 0; c < imgx; c++ ) // for ( int r = 0; r < imgy; r++) // { // addr = rimgx+c; // if(angles->data[addr] == NOTDEF) // edgeimg_out.data[addr] = 0; // else // { // edgeimg_out.data[addr] = 255;//?????????????????????????????? // //------------------------------------------------ // edge_pixels_total_num++; // } // } // cv::imshow("edge detection res", edgeimg_out); // printf("edge pixel number: %i\n",edge_pixels_total_num); // //??????edge_pixels_total_num x 2 ?????????????????????????????????????????????????????????????????????matlab????????? // // plhs[2] = mxCreateDoubleMatrix(2,edge_pixels_total_num,mxREAL); // // gradient_vec_out = (double*)mxGetPr(plhs[2]); // // for ( int c = 0; c < imgx; c++ ) // // for ( int r = 0; r < imgy; r++) // // { // // addr = rimgx+c; // // if(angles->data[addr] != NOTDEF) // // { // // gradient_vec_out[g_cnt++] = cos(angles->data[addr]); // // gradient_vec_out[g_cnt++] = sin(angles->data[addr]); // // } // // } // //--------------------------------------------------------------------- // //??????????????????????????? // // if(nlhs == 4) // { // Mat ls_mat = Mat::zeros(imgy,imgx,CV_8UC3); // image.copyTo(ls_mat); // for ( int i = 0; i<n ; i++)//draw lines // { // Point2d p1(out[8i],out[8i+1]),p2(out[8i+2],out[8i+3]); // line(ls_mat,p1,p2,Scalar(255,0,0)); // } // if(candidates_num > 0)//draw ellipses // { // for ( int i = 0; i<candidates_num; i++) // ellipse(ls_mat,cv::Point((int)candidates_out[i5],(int)candidates_out[i5+1]),cv::Size(candidates_out[i5+2],candidates_out[i5+3]),candidates_out[i5+4]*180/M_PI,0,360,(Scalar(0,255,0)),1); // }

// cv::imshow("seg detection res", ls_mat); // cv::waitKey(0); // // plhs[3] = mxCreateDoubleMatrix(imgy,imgx,mxREAL); // // double * ls_img_out = (double*)mxGetPr(plhs[3]); // //memcpy(ls_out_mat,ls_mat.data ,sizeof(unsigned char)MN); // // for (int i = 0; i<imgx; i++) // // for (int j = 0; j<imgy;j++) // // ls_img_out[iimgy+j]=ls_mat.data[jimgx+i]; // } // //--------------------------------------------------------------------- // //?????????free?????????????????????????????????????????????????????????????????? // free(data); // free(coverages); // free(out); // free_image_double(angles);

// // Mat3b resultImage = image.clone(); // // yaed.DrawDetectedEllipses(resultImage, ellsYaed); // // // // imwrite(out_folder + name + ".png", resultImage); // // // // imshow("Yaed", resultImage); // // waitKey(); // // // // // // int yghds = 0; // }

// return 0; // } // #endif

xiahaa avatar Aug 17 '20 09:08 xiahaa

visual studio

Thank you. I download visual studio software and try it.

real-lixin avatar Aug 17 '20 09:08 real-lixin

try uncomment the following code, and make a visual studio project using this pure c++ code (no mex functions are used). Once you have successfully compiled the code and run without error in visual studio. then I think u can mex compile the code.

// int main(int argc, const char * argv[]) { // // insert code here... // printf("Hello, World!\n");

// std::string images_folder = "/Volumes/document/fore-end/ellipse_detection/thirdparty/detection/High-quality-ellipse-detection-master/pics"; // // "/Volumes/document/fore-end/ellipse_detection/data/test_data"; // std::string out_folder = images_folder; // std::vectorstd::string names; // names.push_back(images_folder+"/"+"27.jpg"); // //glob(images_folder + "Lo3my4.*", names);

// for (const auto& image_name : names) // { // std::string name = image_name.substr(image_name.find_last_of("/") + 1); // name = name.substr(0, name.find_last_of("."));

// Mat3b image = imread(image_name); // Size sz = image.size();

// // Convert to grayscale // Mat1b gray;//1b is one byte // cvtColor(image, gray, CV_BGR2GRAY);

// int edge_process_select = 2; // int specified_polarity = 0;

// int imgy = gray.rows; // int imgx = gray.cols;

// uchar ptr = (uchar)gray.data;

// double data=(double)malloc(imgy_imgx_sizeof(double));//????????????????????????????????????????????????????????? // for(int c=0;c<imgx;c++) // { // for(int r=0;r<imgy;r++) // { // data[c+r_imgx]=ptr[c+r_imgx]; // } // }

// int n;//???????????? // //int new_n; // std::vectorstd::vector groups; // double * coverages; // int * reg; // int reg_x; // int reg_y; // double* out=mylsd(&n, data,imgx,imgy,&reg,&reg_x,&reg_y); // groupLSs(out,n,reg,reg_x,reg_y,&groups);//????????? done. // free(reg); //???????????? // calcuGroupCoverage(out,n,groups,coverages);//??????????????????????????????, done

// printf("The number of output arc-support line segments: %i\n",n); // printf("The number of arc-support groups:%i\n",groups.size());

// image_double angles; // if(edge_process_select == 1) // calculateGradient2(data,imgx,imgy,&angles); //version2, sobel; version 3 canny // else // calculateGradient3(data,imgx,imgy,&angles); //version2, sobel; version 3 canny // PairGroupList * pairGroupList; // double distance_tolerance = 2;//max( 2.0, 0.005*min(angles->xsize,angles->ysize) ); // 0.005%*min(xsize,ysize) // double * candidates; //???????????? // double * candidates_out;//???????????????????????? // int candidates_num = 0;//?????????????????? // //rejectShortLines(out,n,&new_n); // pairGroupList = getValidInitialEllipseSet(out,n,&groups,coverages,angles,distance_tolerance,specified_polarity); // // double *candidates_out = NULL; // if(pairGroupList != NULL) // { // printf("The number of initial ellipses???%i \n",pairGroupList->length); // generateEllipseCandidates(pairGroupList, distance_tolerance, candidates, &candidates_num); // printf("The number of ellipse candidates: %i \n",candidates_num);

// // plhs[0] = mxCreateDoubleMatrix(5,candidates_num,mxREAL); // // candidates_out = (double*)mxGetPr(plhs[0]); // candidates_out = (double *)malloc(sizeof(double)_5_candidates_num); // if (candidates_out == NULL) // { // std::cout << "initialize candidates_out failed!"<<std::endl; // assert(1); // } // //???????????????(xi,yi,ai,bi,phi_i)', 5 x candidates_num, ???????????????candidates_out??? // memcpy(candidates_out,candidates,sizeof(double)_5_candidates_num);

// freePairGroupList(pairGroupList); // free(candidates); // } // else // { // printf("The number of initial ellipses???%i \n",0); // // double candidates_out; // // plhs[0] = mxCreateDoubleMatrix(5,1,mxREAL); // // candidates_out = (double)mxGetPr(plhs[0]); // // candidates_out[0] = candidates_out[1] = candidates_out[2] = candidates_out[3] = candidates_out[4] = 0; // } // // uchar _edgeimg_out; // unsigned long edge_pixels_total_num = 0;//??????????????? // double gradient_vec_out; // // plhs[1] = mxCreateNumericMatrix(imgy,imgx,mxUINT8_CLASS,mxREAL); // // edgeimg_out = (uchar)mxGetData(plhs[1]); // //???????????????????????????edgeimg_out??? // //???????????????????????????gradient_vec_out??? // cv::Mat edgeimg_out(imgy,imgx,CV_8UC1); // unsigned long addr,g_cnt = 0; // for ( int c = 0; c < imgx; c++ ) // for ( int r = 0; r < imgy; r++) // { // addr = r_imgx+c; // if(angles->data[addr] == NOTDEF) // edgeimg_out.data[addr] = 0; // else // { // edgeimg_out.data[addr] = 255;//?????????????????????????????? // //------------------------------------------------ // edge_pixels_total_num++; // } // } // cv::imshow("edge detection res", edgeimg_out); // printf("edge pixel number: %i\n",edge_pixels_total_num); // //??????edge_pixels_total_num x 2 ?????????????????????????????????????????????????????????????????????matlab????????? // // plhs[2] = mxCreateDoubleMatrix(2,edge_pixels_total_num,mxREAL); // // gradient_vec_out = (double*)mxGetPr(plhs[2]); // // for ( int c = 0; c < imgx; c++ ) // // for ( int r = 0; r < imgy; r++) // // { // // addr = r_imgx+c; // // if(angles->data[addr] != NOTDEF) // // { // // gradient_vec_out[g_cnt++] = cos(angles->data[addr]); // // gradient_vec_out[g_cnt++] = sin(angles->data[addr]); // // } // // } // //--------------------------------------------------------------------- // //??????????????????????????? // // if(nlhs == 4) // { // Mat ls_mat = Mat::zeros(imgy,imgx,CV_8UC3); // image.copyTo(ls_mat); // for ( int i = 0; i<n ; i++)//draw lines // { // Point2d p1(out[8_i],out[8_i+1]),p2(out[8_i+2],out[8_i+3]); // line(ls_mat,p1,p2,Scalar(255,0,0)); // } // if(candidates_num > 0)//draw ellipses // { // for ( int i = 0; i<candidates_num; i++) // ellipse(ls_mat,cv::Point((int)candidates_out[i_5],(int)candidates_out[i_5+1]),cv::Size(candidates_out[i_5+2],candidates_out[i_5+3]),candidates_out[i_5+4]*180/M_PI,0,360,(Scalar(0,255,0)),1); // }

// cv::imshow("seg detection res", ls_mat); // cv::waitKey(0); // // plhs[3] = mxCreateDoubleMatrix(imgy,imgx,mxREAL); // // double * ls_img_out = (double*)mxGetPr(plhs[3]); // //memcpy(ls_out_mat,ls_mat.data ,sizeof(unsigned char)_M_N); // // for (int i = 0; i<imgx; i++) // // for (int j = 0; j<imgy;j++) // // ls_img_out[i_imgy+j]=ls_mat.data[j_imgx+i]; // } // //--------------------------------------------------------------------- // //?????????free?????????????????????????????????????????????????????????????????? // free(data); // free(coverages); // free(out); // free_image_double(angles);

// // Mat3b resultImage = image.clone(); // // yaed.DrawDetectedEllipses(resultImage, ellsYaed); // // // // imwrite(out_folder + name + ".png", resultImage); // // // // imshow("Yaed", resultImage); // // waitKey(); // // // // // // int yghds = 0; // }

// return 0; // } // #endif

What is the VS version you use? Then I download the same version and try.

real-lixin avatar Aug 17 '20 09:08 real-lixin

it does not matter. You have vc11. You just create a new project and copy paste this code to a main.cpp, add Lu's cpp code, comment. Compile, it will produce some errors related to mex, just comment mex related code. Compile-comment until you can compile without problem.

xiahaa avatar Aug 17 '20 09:08 xiahaa

it does not matter. You have vc11. You just create a new project and copy paste this code to a main.cpp, add Lu's cpp code, comment. Compile, it will produce some errors related to mex, just comment mex related code. Compile-comment until you can compile without problem.

I wonder if it's the compiler problem. Because I haven't installed VS and I have been using Mingw for mex.

real-lixin avatar Aug 17 '20 09:08 real-lixin

You haven't install vs. Then why you have opencv compiled in a folder called vc11? How did you install opencv? You compiled from source or the other way?

xiahaa avatar Aug 17 '20 09:08 xiahaa

You haven't install vs. Then why you have opencv compiled in a folder called vc11? How did you install opencv? You compiled from source or the other way?

I download OpenCV, then get the unzip file. In the folderD:\Program Files\opencv_2.4.9\build\x64, there are three foldersvc10, vc11, vc12

real-lixin avatar Aug 17 '20 09:08 real-lixin

omg..... Then I am not sure coz I always compile from source. It could be the compiler problem as u supposed.

Maybe u can try download vs, and then mex --setup to set ur c++ compiler to vs2011 or so. And then try again.

xiahaa avatar Aug 17 '20 09:08 xiahaa

omg..... Then I am not sure coz I always compile from source. It could be the compiler problem as u supposed.

Maybe u can try download vs, and then mex --setup to set ur c++ compiler to vs2011 or so. And then try again.

Yes, I have been using Mingw, not the VS.

real-lixin avatar Aug 17 '20 09:08 real-lixin

Yeah I had problems using Mingw. I recently switched to vs2013 which resolved my issue (which appears similar to yours). I am also using r2016b version of Matlab.

GarrettFrank avatar Aug 17 '20 18:08 GarrettFrank

omg..... Then I am not sure coz I always compile from source. It could be the compiler problem as u supposed.

Maybe u can try download vs, and then mex --setup to set ur c++ compiler to vs2011 or so. And then try again.

I installed VS2015 and compile, but still have an error: Incorrect use of MEX generateEllipseCandidates.cpp d:\program files\matlab\r2017a\extern\include\matrix.h(23): fatal error C1083: Unable to open include file: "stdlib.h" : No such file or Directory

real-lixin avatar Aug 18 '20 08:08 real-lixin

Yeah I had problems using Mingw. I recently switched to vs2013 which resolved my issue (which appears similar to yours). I am also using r2016b version of Matlab.

You have solved the mex compile error? But I still have a problem. When I use VS2015 to mex, it tells me some files cannot be opened.

real-lixin avatar Aug 18 '20 08:08 real-lixin

For ur case, do not go directly to mex compile. U just create a vs project, add the generateEllipseCandidates.cpp, compile, the first time it will produce lots of errors related to mex, just comment those lines like #include "mex.h", etc. compile, comment, repeat this until u can compile successfully. VS will produce more details about what u r missing. Try fix them first, then go with mex. It is almost impossible to meet the error that can not open "stdlib.h" coz it is a part of the c++ library.

xiahaa avatar Aug 18 '20 08:08 xiahaa

For ur case, do not go directly to mex compile. U just create a vs project, add the generateEllipseCandidates.cpp, compile, the first time it will produce lots of errors related to mex, just comment those lines like #include "mex.h", etc. compile, comment, repeat this until u can compile successfully. VS will produce more details about what u r missing. Try fix them first, then go with mex. It is almost impossible to meet the error that can not open "stdlib.h" coz it is a part of the c++ library.

That's probably the best way.

real-lixin avatar Aug 18 '20 08:08 real-lixin

For ur case, do not go directly to mex compile. U just create a vs project, add the generateEllipseCandidates.cpp, compile, the first time it will produce lots of errors related to mex, just comment those lines like #include "mex.h", etc. compile, comment, repeat this until u can compile successfully. VS will produce more details about what u r missing. Try fix them first, then go with mex. It is almost impossible to meet the error that can not open "stdlib.h" coz it is a part of the c++ library.

@xiahaa @GarrettFrank The whole process just like epic. After many attempts, the problem was finally solved. I repeatedly installed and uninstalled VS2015, and the problem persisted. Finally, I uninstalled VS2015 and installed VS2013 , which solved the problem. Thank you very much for your kindly advice. Now I feel very good.

real-lixin avatar Aug 18 '20 10:08 real-lixin