When does Jetpack support OpenVX 1.2?

When does Jetpack support OpenVX 1.2?

Hi mitonatto,

May I know why this is so important for your project?
Any blocking there? Or new feature requirement?

Thanks

Hi kayccc,

It is POC project.
I want to use template matching.
However, template matching does not work with opencv, openvx.

Is it a simple algorithm so I should implement it myself?

Thanks.

Hi,

For OpenCV part, it should work if you compile it with the correct GPU architecture and CUDA version.
Have you built it from source? If yes, could you share the command you used for cmake?

We have verified some OpenCV implement on Xavier and it works correctly.
Please check you are using the similar installation procedure of this:
https://github.com/AastaNV/JEP/blob/master/script/install_opencv4.0.0_Xavier.sh

And please let us know if it is still not working after following the above steps.

Thanks.

Hi AastaLLL,

I tried installing again in the way you introduced me, but it did not work as well.
Run it on another PC’s CUDA 9 and it will run.

#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/calib3d.hpp>
#include <opencv2/cudaimgproc.hpp>
#include <opencv2/cudaarithm.hpp>
#include <iostream>
#include <string>

int main(int argc, char** argv) {

    cv::cuda::setDevice(0); // initialize CUDA
    cv::Mat result_h;   
    cv::Mat image_h = cv::imread(argv[1]); // input
    cv::Mat templ_h = cv::imread(argv[2]); // template 

    // convert from mat to gpumat
    cv::cuda::GpuMat image_d(image_h);
    cv::cuda::GpuMat templ_d(templ_h);
    cv::cuda::GpuMat result;

    // GPU -> NG
    std::cout << "debug msg 1" << std::endl;
    cv::Ptr<cv::cuda::TemplateMatching> alg = cv::cuda::createTemplateMatching(image_h.type(), cv::TM_CCOEFF_NORMED);
    std::cout << "debug msg 2" << std::endl;
    alg->match(image_d, templ_d, result);  // no return.
    std::cout << "debug msg 3" << std::endl;

    cv::cuda::normalize(result, result, 0, 1, cv::NORM_MINMAX, -1);
    double max_value;
    cv::Point location;
    cv::cuda::minMaxLoc(result, 0, &max_value, 0, &location);

/*
    // CPU -> OK
    cv::matchTemplate(image_h, templ_h, result_h, cv::TM_CCOEFF_NORMED);
    cv::normalize(result_h, result_h, 0, 1, cv::NORM_MINMAX, -1);
    double max_value;
    cv::Point location;
    cv::minMaxLoc(result_h, 0, &max_value, 0, &location);
*/
    std::cout << "======Test Match Template======" << std::endl;
    std::cout << "input :" << argv[1] << std::endl;
    std::cout << "template :" << argv[2] << std::endl;
    std::cout << " " << std::endl;

    return 0;
}

Thanks.

Thanks, mitonatto.

We will check this issue and update information with you later.

Hi,

What error do you meet?
I can execute this command without error: cuda::createTemplateMatching

Thanks.

I can do it, too.
However, there is no error, and no reply is returned at “alg-> match”.

$./main input.png template.png
debug msg 1
debug msg 2
(“debug msg 3”  is not responding )

Okay.

We can also reproduce this.
Let us check the source code first and update to you.

Thanks.

Hi,

We found that program get stuck in this cuda::integral function.
https://github.com/opencv/opencv_contrib/blob/master/modules/cudev/include/opencv2/cudev/grid/detail/integral.hpp#L601

It looks like this value need to be updated with the Xavier architecture.
We are still checking this in detail. Will update more information with you later.

Thanks.

Hi AastaLLL,

Thank you for your investigation.
If it seems difficult to modify the program, I will consider another way.

Hi,

Just found that our NPP library also has template matching implementation.
You can give it a try.
https://docs.nvidia.com/cuda/npp/group__image__proximity.html

Thanks.

@AastaLLL
May be you have an idea of how to get pkg-config to recognize the scripted opencv4 installation?

g++ -o simple_opencv -Wall -std=c++11 simple_opencv.cpp $(pkg-config --libs opencv)
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found
simple_opencv.cpp:2:10: fatal error: opencv2/opencv.hpp: No such file or directory
 #include <opencv2/opencv.hpp>
          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.

Hi Andrey1984,

$ vim ./install_opencv4.0.0_Xavier.sh

// add OPENCV_GENERATE_PKGCONFIG option
cmake -D WITH_CUDA=ON 
      -D OPENCV_GENERATE_PKGCONFIG=ON \
      -D CUDA_ARCH_BIN="7.2" \
      -D CUDA_ARCH_PTX="" \
      -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.0.0/modules \
      -D WITH_GSTREAMER=ON \
      -D WITH_LIBV4L=ON \
      -D BUILD_TESTS=OFF \
      -D BUILD_PERF_TESTS=OFF \
      -D BUILD_EXAMPLES=OFF \
      -D CMAKE_BUILD_TYPE=RELEASE \
      -D CMAKE_INSTALL_PREFIX=/usr/local ..
$ g++ -o sample sample.cpp `pkg-config --cflags opencv4` `pkg-config --libs opencv4` --std=c++11

can you run attached code with it?
source: https://devtalk.nvidia.com/default/topic/1042892/jetson-agx-xavier/nvarguscamerasrc-opencv-solved-/
In my case it returns:

nano simple_opencv.cpp
nvidia@jetson-0423018055033:~$ g++ -o simple_opencv simple_opencv.cpp `pkg-config --cflags opencv4` `pkg-config --libs opencv4` --std=c++11
simple_opencv.cpp: In function ‘int main(int, char**)’:
simple_opencv.cpp:22:28: error: ‘CV_YUV2BGR_I420’ was not declared in this scope
       cvtColor(frame, bgr, CV_YUV2BGR_I420);

Thank you.
simple_opencv.cpp (611 Bytes)

That code was verified with OpenCV3.4.0.
For OpenCV4.0, you should try “COLOR_YUV2BGR_I420” instead.

refrence:
https://docs.opencv.org/4.0.0/d8/d01/group__imgproc__color__conversions.html

Thank you.