Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV 4.1.2 CUDA 10 Python on Jeton TX2 Jetpack 4.2

Hello,

I´m using the cv2.calcOpticalFlowFarneback() function on my Jetson TX2 with Python, but unfortunately I´m not getting any improvement in performance after building OpenCV 4.1.2 from source with CUDA support. As long as I know, since OpenCV4, all the functions are optimized and integrated by default, but apparently CUDA optimized functions are not implemented with python Wrappers.

So my goal would be to access the class cv::cuda::FarnebackOpticalFlow to calculate the Optical Flow from a pair of images.

I tried to used the python wrapper for farnerback on gpu developed here https://github.com/NeerajGulia/python-opencv-cuda, and I ran the tests, it can do it at a rate of 9 FPS with a test video, compared to the 4 FPS using the normal opencv4 cuda build optimized.

So because I´m new with OpenCV I´d like to know:

1) Is it possible to access OpenCV cv::cuda::FarnebackOpticalFlow class from Python on my Jetson TX2 from Python? I´m currently trying to call calc function from Python like this: opticalFlowGPU = cv.cuda_FarnebackOpticalFlow.create(5, 0.5, False, 15, 3, 5, 1.2, 0) flowCUDA = opticalFlowGPU.calc(frame1, frame2, None)

but I get the following error when I call calc function: Exception has occurred: error OpenCV(4.1.2) /home/nvidia/opencv-4.1.2/modules/core/src/matrix_wrap.cpp:359: error: (-213:The function/feature is not implemented) getGpuMat is available only for cuda::GpuMat and cuda::HostMem in function 'getGpuMat

2) I know Nvidia has developed the new OpticalFlow SDK https://developer.nvidia.com/opticalflow-sdk. But I think the Jetson TX2 is not compatible because of the GPU architecture because. Is it posible to build the OpticalFlow SDK for the TX2 so I don´t get an error?

Thanks