我正在尝试使用cv :: SparseMat。以下是我的测试程序
int main( int argc, char ** argv )
{
cout<<"Sparse Matrix Test...\n";
int sizes[] = { 100, 100 };
cv::SparseMat mySMat(2, sizes, CV_8U );
mySMat.ref<uchar>(5) = 10;
return 0;
}
我将其编译为:
g++ -o "HelloOpenCV2" ./src/HelloOpenCV2.o -lopencv_core -lopencv_calib3d -lopencv_imgproc -lopencv_highgui -lopencv_features2d
编译器抛出以下错误:
HelloOpenCV2.cpp:(.text.startup+0x5c): undefined reference to `cv::SparseMat::ptr(int, bool, unsigned long*)'
collect2: ld returned 1 exit status
make: *** [HelloOpenCV2] Error 1
我可以确认使用cv :: Mat的正常opencv2程序工作得很好。
答案 0 :(得分:0)
// 2d , use 2d index:
cout<<"Sparse Matrix Test...\n";
int sizes[] = { 100, 100 };
cv::SparseMat mySMat(2, sizes, CV_8U );
mySMat.ref<uchar>(0,5) = 10;
// 1d, use 1d index:
int sizes1[] = { 100 };
cv::SparseMat mySMat1(1, sizes1, CV_8U );
mySMat1.ref<uchar>(5) = 10;