OpenCV convertTo Failure

I have code which worked on a TX1 which fails on the TX2 :

#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
using namespace std;
using namespace cv;

int main(void)
{
	Mat foo;
	gpu::GpuMat f32Mat;
	gpu::GpuMat(foo).convertTo(f32Mat, CV_32FC3);
	return 0;
}
OpenCV Error: Gpu API call (invalid device function) in call, file /hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/gpu/include/opencv2/gpu/device/detail/transform_detail.hpp, line 361
terminate called after throwing an instance of 'cv::Exception'
  what():  /hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/gpu/include/opencv2/gpu/device/detail/transform_detail.hpp:361: error: (-217) invalid device function in function call

Aborted (core dumped)

Any ideas on how to fix this?

Hi,

Thanks for your question.

Just tried your code on tx1 with JepPack2.3.1.
Also meet the same error.

OpenCV Error: Gpu API call (invalid configuration argument) in call, file /hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/gpu/include/opencv2/gpu/device/detail/transform_detail.hpp, line 361
terminate called after throwing an instance of 'cv::Exception'
  what():  /hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/gpu/include/opencv2/gpu/device/detail/transform_detail.hpp:361: error: (-217) invalid configuration argument in function call

Aborted

Could you help us check if this code can be successfully executed on TX1?

Had a chance to double-check this on my TX1. This seems to fail only if the Mat is empty. Looks like this is just a side effect of other problems in my code while porting to the TX2.

Sorry for the false alarm and thanks for checking into this.

I had a chance to try and debug the problem and I think there’s still a problem here. The reduced test case failed on both TX1 and TX2. Changing the foo object to a non-empty Mat makes it work on a TX1 but fail on the TX2 :

#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
using namespace std;
using namespace cv;

int main(void)
{
	Mat foo = Mat::eye(640,480,CV_8UC3);
	gpu::GpuMat f32Mat;
	gpu::GpuMat(foo).convertTo(f32Mat, CV_32FC3);
	return 0;
}
OpenCV Error: Gpu API call (invalid device function) in call, file /hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/gpu/include/opencv2/gpu/device/detail/transform_detail.hpp, line 361
terminate called after throwing an instance of 'cv::Exception'
  what():  /hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/gpu/include/opencv2/gpu/device/detail/transform_detail.hpp:361: error: (-217) invalid device function in function call

Could you see if you can reproduce on your end?

Hi,

Thanks for your question.

We found this issue recently.
Currently, libopencv_gpu.so can’t be used on TX2 since wrong compute architecture.
Please refer to topic 1000701 for more details: https://devtalk.nvidia.com/default/topic/1000701

We are really sorry about this issue. For temporally solution, please build opencv from source.
Opencv2.4.13:
http://docs.opencv.org/master/d6/d15/tutorial_building_tegra_cuda.html#tutorial_building_tegra_cuda_opencv_24X
Opencv3.x:
https://devtalk.nvidia.com/default/topic/983098/jetson-tx1/opencv-3-1-with-usb-camera-support/

We are working on this issue and will update information to you soon.
Thanks and sorry for all the inconvenience.

Hi,

Same problem here with gpu::remap and many others gpu functions on TX2.

Are there any update to solve this?

Thanks!

Hi,

We are working on this issue and will update information soon.

For temporal solution, please build opencv from source.
Opencv2.4.13:
http://docs.opencv.org/master/d6/d15/tutorial_building_tegra_cuda.html#tutorial_building_tegra_cuda_opencv_24X
Opencv3.x:
https://devtalk.nvidia.com/default/topic/983098/jetson-tx1/opencv-3-1-with-usb-camera-support/

We are so sorry for the inconvenience and really thank you for your patience.

Ok AastaLLL,

I built opencv for TX2 with no problems and I will keep waiting for the update!

Thanks!

Please I have followed the following links you provided for Tegra X2:
Opencv2.4.13:
http://docs.opencv.org/master/d6/d15/tutorial_building_tegra_cuda.html#tutorial_building_tegra_cuda_opencv_24X
Opencv3.x:
https://devtalk.nvidia.com/default/topic/983098/jetson-tx1/opencv-3-1-with-usb-camera-support/

Opencv2.4.13 or 2.4.13.2 neither of them works with 6.2 as architecture.
Tried and installed Opencv3.x, might be working but I do not want to change my source code ( it gives me lots of compilation errors unlike 2.4.13)

The point is that when I try Opencv3.x, Tegra X2’s cuda generation(one option in CCmake program) lists Pascal along with kepler and other architectures but when I compile 2.4.13.x it is not listed there so that “Auto” option does not know Pascal architecture to compile this version of Opencv properly, architecture is changed to 6.2 though.

Jetpack installs but GPU functions are NOT working. I tried to test opencv functions using this link http://elinux.org/Jetson/Installing_OpenCV

I have Tegra X1 and the same source code works perfectly there (webcam also detected);however, I can compile the same source code on Tegra X2 (no compilation errors), but with run time error (mostly API call exceptions.

As our friends recommended above , I changed the architecture to 6.2 and compiled using the most recent Cmake version and still stuck at the same run time error after I get my code compiled.
Please give us a better solution rather than forwarding us to the links we already know.

Jetpack must be working normally and we do not have to compile opencv from scratch , it is not working though
Please give us an illustrated way of installation that you have tried on tegra X2 in such a way that opencv functions samples really work …

Thank you !

Hi Masoud_afra,

Sorry for the inconvenience.
We will check opencv2.4.13 and update information to you soon.

Thanks.

Hi,

Just confirmed that opencv-2.4.13 can build without error on TX2.
I write a script to automatically build opencv-2.4.13 from source.

Steps:
1. Flash with JetPack3.0
2. unzip build_opencv2.4.13.zip
3. ./build_opencv2.4.13.sh <path/you/want/to/install>
Ex. ./build_opencv2.4.13.sh /media/nvidia/NVIDIA/

Let me know if you still met error.
build_opencv2.4.13.zip (1.06 KB)

Dear AastaLLL,

I think you got me wrong. Two installation methods for Opencv4tegra either from source or Jetpack(using a host PC) has no problem in my case. The real problem is when I try to test opencv with GPU once installations are over (without error). I use the following command to test a GPU accelerated OpenCV sample:

cd …/gpu
g++ houghlines.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_calib3d -lopencv_contrib -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_legacy -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_video -lopencv_videostab -o houghlines
./houghlines …/cpp/logo_in_clutter.png

Regardless of the fact that I have tried either ways above and installation was done successfully on Tegra X2, I tried one more time as you recommended and here is the problem :


root@tegra-ubuntu:~/opencv-2.4.13/samples/gpu# g++ houghlines.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_calib3d -lopencv_contrib -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_legacy -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_video -lopencv_videostab -o houghlines

root@tegra-ubuntu:~/opencv-2.4.13/samples/gpu# ./houghlines …/cpp/logo_in_clutter.png
CPU Time : 50.5794 ms
CPU Found : 39
OpenCV Error: Gpu API call (invalid device symbol) in buildPointList_gpu, file /home/ubuntu/opencv-2.4.13/modules/gpu/src/cuda/build_point_list.cu, line 116
terminate called after throwing an instance of ‘cv::Exception’
what(): /home/ubuntu/opencv-2.4.13/modules/gpu/src/cuda/build_point_list.cu:116: error: (-217) invalid device symbol in function buildPointList_gpu

Aborted (core dumped)

Any ideas please?

Hi,

Yesterday, we also checked the GPU functionality. It works well.
Double confirm the houghlines sample, and it works correctly without error. Please check attachment.

Could you try it again?
Please also check if your opencv2.4.13 build successfully.

Thanks.

Oh God, I am so excited :)

I did one last time and it did work. started with a clean install and flashed Tegra X2 plus Jetpack3.
Later I ran the same file you provided and it works just as I expected but there is a problem with camera now.
Camera is not detected here while on Tegra X1 it was detectable. V4l libraries are required to be built too ?

On Tegra X1 also I used to receive this message : “HIGHGUI ERROR: V4L2: Pixel format of incoming image is unsupported by openCV” but only this message was shown and camera frames was shown online. Now with Tegra X2, first of all NVCC is missing so that I used g++ instead and the same message is shown but camera is not shown after.

I suppose that we missed a library which is for camera to be built … Would you please let me know how to fix this last problem ?

Thanks for your help indeed ^^

FYI, I am using Logitech Webcam C930e and it is listed using ‘lsusb’ command.

Regarding NVCC, it was installed but path to it had to be saved in .bashrc file.

So I fixed the NVCC problem with the following commands :
$ export PATH="usr/local/cuda/bin:PATH" source .bashrc

Now NVCC can be used to compile source codes as well as G++.

Still struggling to get my camera working on Tegra X2 too :/

Hi,

Opencv open webcam correctly in my environment.

import cv2

cap = cv2.VideoCapture(0)

while(True):
    ret, frame = cap.read()

    cv2.imshow('frame', frame)
    cv2.waitKey(1)

Could you try it again?

I did try and only a black frame (no image in it).
This time no error monitored though.

Even Cheese software from Ubuntu shows a black screen ?! :/