int main(){
Mat image=imread("lena512color.tiff",CV_LOAD_IMAGE_COLOR);
nameWindow("image",WINDOW_AUTOSIZE);
imshow("image",image);
waitKey(0);
return 0;
}
I want to use gpu accelerator and cuda for image processing operations so i can't use python.
When I run the code, I get this error:
/tmp/tmpxft_000069af_00000000-10_55e6dc62-abd3-4eda-9726-8fe871a274ee.o: In function main':
tmpxft_000069af_00000000-5_55e6dc62-abd3-4eda-9726-8fe871a274ee.cudafe1.cpp:(.text+0x6d): undefined reference tocv::imread(cv::String const&, int)'
tmpxft_000069af_00000000-5_55e6dc62-abd3-4eda-9726-8fe871a274ee.cudafe1.cpp:(.text+0x106): undefined reference to cv::namedWindow(cv::String const&, int)'
tmpxft_000069af_00000000-5_55e6dc62-abd3-4eda-9726-8fe871a274ee.cudafe1.cpp:(.text+0x15d): undefined reference tocv::imshow(cv::String const&, cv::_InputArray const&)'
tmpxft_000069af_00000000-5_55e6dc62-abd3-4eda-9726-8fe871a274ee.cudafe1.cpp:(.text+0x185): undefined reference to `cv::waitKey(int)'
/tmp/tmpxft_000069af_00000000-10_55e6dc62-abd3-4eda-9726-8f
tmpxft_000069af_00000000-5_55e6dc62-abd3-4eda-9726-8fe871a274ee.cudafe1.cpp:(.text._ZN2cv6StringaSERKS0_[_ZN2cv6StringaSERKS0_]+0x28): undefined reference to cv::String::deallocate()'
/tmp/tmpxft_000069af_00000000-10_55e6dc62-abd3-4eda-9726-8fe871a274ee.o: In functioncv::Mat::~Mat()':
tmpxft_000069af_00000000-5_55e6dc62-abd3-4eda-9726-8fe871a274ee.cudafe1.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to cv::fastFree(void*)'
/tmp/tmpxft_000069af_00000000-10_55e6dc62-abd3-4eda-9726-8fe871a274ee.o: In functioncv::Mat::release()':
tmpxft_000069af_00000000-5_55e6dc62-abd3-4eda-9726-8fe871a274ee.cudafe1.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x4b): undefined reference to `cv::Mat::deallocate()'
/tmp/tmpxft_000069af_00000000-10_55e6dc62-abd3-4eda-9726-8
/tmp/tmpxft_000069af_00000000-10_55e6dc62-abd3-4eda-9726-8fe871a274ee.o: In function cv::Mat::release()':
tmpxft_000069af_00000000-5_55e6dc62-abd3-4eda-9726-8fe871a274ee.cudafe1.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x4b): undefined reference tocv::Mat::deallocate()'
/tmp/tmpxft_000069af_00000000-10_55e6dc62-abd3-4eda-9726-8fe871a274ee.o: In function cv::Mat::operator=(cv::Mat&&)':
tmpxft_000069af_00000000-5_55e6dc62-abd3-4eda-9726-8fe871a274ee.cudafe1.cpp:(.text._ZN2cv3MataSEOS0_[_ZN2cv3MataSEOS0_]+0xe7): undefined reference tocv::fastFree(void*)'
collect2: error: ld returned 1 exit status
Thanks.I have to use cuda and opencv for image processing on gpu accelerator. I am an absolute beginner in opencv so I can’t understand you very well. How can I use suitable libraries?And how can I build the libs locally?
to use CUDA from c++, you would have to install the resp. CUDA sdk on colab first. then you would have to builld the opencv libs, then you can build your program.
a lot of tedious work, definitely NOT for a complete noob (to basic c++ even) like you.
your link is not helpful.
we need to see what you did, and where it failed
also never helpful
also: why not use python there ? (latest 4.2.0 is installed by default !)
I run below code: %%cu
include <iostream>
include <stdio.h>
include <opencv2 core="" core.hpp="">
include <opencv2 highgui="" highgui.hpp="">
include <opencv2 opencv.hpp="">
inlcude "opencv2/imageproc/imageproc.hpp""
using namespace cv; using namespace std;
int main(){ Mat image=imread("lena512color.tiff",CV_LOAD_IMAGE_COLOR); nameWindow("image",WINDOW_AUTOSIZE); imshow("image",image); waitKey(0); return 0; }
I want to use gpu accelerator and cuda for image processing operations so i can't use python.
When I run the code, I get this error: /tmp/tmpxft_000069af_00000000-10_55e6dc62-abd3-4eda-9726-8fe871a274ee.o: In function
main': tmpxft_000069af_00000000-5_55e6dc62-abd3-4eda-9726-8fe871a274ee.cudafe1.cpp:(.text+0x6d): undefined reference to
cv::imread(cv::String const&, int)' tmpxft_000069af_00000000-5_55e6dc62-abd3-4eda-9726-8fe871a274ee.cudafe1.cpp:(.text+0x106): undefined reference tocv::namedWindow(cv::String const&, int)' tmpxft_000069af_00000000-5_55e6dc62-abd3-4eda-9726-8fe871a274ee.cudafe1.cpp:(.text+0x15d): undefined reference to
cv::imshow(cv::String const&, cv::_InputArray const&)' tmpxft_000069af_00000000-5_55e6dc62-abd3-4eda-9726-8fe871a274ee.cudafe1.cpp:(.text+0x185): undefined reference to `cv::waitKey(int)' /tmp/tmpxft_000069af_00000000-10_55e6dc62-abd3-4eda-9726-8ftmpxft_000069af_00000000-5_55e6dc62-abd3-4eda-9726-8fe871a274ee.cudafe1.cpp:(.text._ZN2cv6StringaSERKS0_[_ZN2cv6StringaSERKS0_]+0x28): undefined reference to
cv::String::deallocate()' /tmp/tmpxft_000069af_00000000-10_55e6dc62-abd3-4eda-9726-8fe871a274ee.o: In function
cv::Mat::~Mat()': tmpxft_000069af_00000000-5_55e6dc62-abd3-4eda-9726-8fe871a274ee.cudafe1.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference tocv::fastFree(void*)' /tmp/tmpxft_000069af_00000000-10_55e6dc62-abd3-4eda-9726-8fe871a274ee.o: In function
cv::Mat::release()': tmpxft_000069af_00000000-5_55e6dc62-abd3-4eda-9726-8fe871a274ee.cudafe1.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x4b): undefined reference to `cv::Mat::deallocate()' /tmp/tmpxft_000069af_00000000-10_55e6dc62-abd3-4eda-9726-8/tmp/tmpxft_000069af_00000000-10_55e6dc62-abd3-4eda-9726-8fe871a274ee.o: In function
cv::Mat::release()': tmpxft_000069af_00000000-5_55e6dc62-abd3-4eda-9726-8fe871a274ee.cudafe1.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x4b): undefined reference to
cv::Mat::deallocate()' /tmp/tmpxft_000069af_00000000-10_55e6dc62-abd3-4eda-9726-8fe871a274ee.o: In functioncv::Mat::operator=(cv::Mat&&)': tmpxft_000069af_00000000-5_55e6dc62-abd3-4eda-9726-8fe871a274ee.cudafe1.cpp:(.text._ZN2cv3MataSEOS0_[_ZN2cv3MataSEOS0_]+0xe7): undefined reference to
cv::fastFree(void*)' collect2: error: ld returned 1 exit statusplease put all of this * into your question* not into comments, thank you.
you're not linking to any opencv libs like
-opencv_core
you also have to build the libs locally, before you can use them, did you do that ?
again, colab might not be the best place to run c++ code, consider using python instead
Thanks.I have to use cuda and opencv for image processing on gpu accelerator. I am an absolute beginner in opencv so I can’t understand you very well. How can I use suitable libraries?And how can I build the libs locally?
to use CUDA from c++, you would have to install the resp. CUDA sdk on colab first. then you would have to builld the opencv libs, then you can build your program.
a lot of tedious work, definitely NOT for a complete noob (to basic c++ even) like you.
you CAN use GPU/TPU on colab, but only with their prebuilt tf / pytorch libraries (from python)
and again, the tutorial you tried with does NOT handle CUDA