buildOpenCVTX2 icon indicating copy to clipboard operation
buildOpenCVTX2 copied to clipboard

How to activate OpenCV on python3

Open Ata1362 opened this issue 5 years ago • 7 comments

Ata1362 avatar May 06 '19 01:05 Ata1362

hi guys, I followed the instruction and codes worked just perfect. I have python 2 and 3 both installed on my Jetson tx2 and they are working fine. after installing the OpenCV the CV2 is only can be import in Python2 NOT 3. How can I make python3 to recognize or find the LIB files. I tried to find the files and maybe copy them to the same directory for python3 but I could not find files. BTW I have installed the opencv all in default directories. Kindly please advise. thank you.

Ata1362 avatar May 06 '19 01:05 Ata1362

I found the files and libs installed on my Jetson. btw, I'm still looking forward to find out how can make python3 to recognize CV2

Ata1362 avatar May 06 '19 01:05 Ata1362

i think,you can copy file to

$ sudo cp /usr/local/lib/python3.5/site-packages/cv2.cpython-35m-aarch64-linux-gnu.so /usr/local/lib/python3.5/dist-packages/cv2.so

$ ls /usr/local/lib/python3.5/dist-packages/cv2.* /usr/local/lib/python3.5/dist-packages/cv2.cpython-35m-aarch64-linux-gnu.so $ ls /usr/local/lib/python2.7/dist-packages/cv2.* /use/local/lib/python2.7/dist-packages/cv2.so $ python3 -c 'import cv2; print(cv2.version)' 3.4.1-dev $ python2 -c 'import cv2; print(cv2.version)' 3.4.1-dev

majiang2018 avatar Sep 04 '20 05:09 majiang2018

https://jkjung-avt.github.io/opencv3-on-tx2/

majiang2018 avatar Sep 04 '20 06:09 majiang2018

you need use nvidia sdkmanage update os to ubuntu18.04

update ./buidOpenCVTX2.sh file

OPENCV_VERSION=4.2.0

time cmake -D CMAKE_BUILD_TYPE=RELEASE
-D CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-D WITH_CUDA=ON
-D CUDA_ARCH_BIN=${ARCH_BIN}
-D CUDA_ARCH_PTX=""
-D ENABLE_FAST_MATH=ON
-D CUDA_FAST_MATH=ON
-D WITH_CUBLAS=ON
-D WITH_LIBV4L=ON
-D WITH_GSTREAMER=ON
-D WITH_GSTREAMER_0_10=OFF
-D WITH_QT=ON
-D WITH_OPENGL=ON
-D OPENCV_EXTRA_MODULES_PATH=/home/nvidia/opencv_contrib/modules
-D CUDNN_LIBRARY=/usr/local/cuda/lib64/libcudnn.so.8.0.0
-D CUDNN_VERSION='8.0'
../

majiang2018 avatar Sep 08 '20 09:09 majiang2018

Thank you for answering my question. I appreciate it a lot. I have removed my Python2, and nowadays, I only use python3, and works just perfect. I hope that your answer will help those that are still having two pythons on their system.

Ata1362 avatar Sep 10 '20 12:09 Ata1362

Hello @Ata1362 did @majiang2018 's solution work for opencv_contrib?

berkantay avatar Dec 03 '20 16:12 berkantay