hi friends.I want to install opencv on google colab for image processing but I couldn't do it.I also used the link below but to no result.

asked 2020-03-27 02:01:43 -0600

updated 2020-03-27 15:04:35 -0600

edit retag flag offensive close merge delete

Comments

your link is not helpful.

we need to see what you did, and where it failed

to no result.

also never helpful

also: why not use python there ? (latest 4.2.0 is installed by default !)

berak gravatar imageberak ( 2020-03-27 03:54:17 -0600 )edit

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.

majid kakavandi gravatar imagemajid kakavandi ( 2020-03-27 05:10:32 -0600 )edit

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

majid kakavandi gravatar imagemajid kakavandi ( 2020-03-27 05:13:38 -0600 )edit

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

majid kakavandi gravatar imagemajid kakavandi ( 2020-03-27 05:14:05 -0600 )edit

/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

majid kakavandi gravatar imagemajid kakavandi ( 2020-03-27 05:14:34 -0600 )edit

please put all of this * into your question* not into comments, thank you.

berak gravatar imageberak ( 2020-03-27 12:22:15 -0600 )edit

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

berak gravatar imageberak ( 2020-03-28 02:28:24 -0600 )edit

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?

majid kakavandi gravatar imagemajid kakavandi ( 2020-03-28 03:14:46 -0600 )edit

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.

berak gravatar imageberak ( 2020-03-28 04:26:19 -0600 )edit

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

berak gravatar imageberak ( 2020-03-28 04:29:04 -0600 )edit