I want to call cv::findCountours on some cv::UMat (OpenCL activated) and get the results into std::vector<std::vector<cv::Point>>.
std::vector<std::vector<cv::Point>> contours;
cv::findContours(frame_umat, contours, cv::RETR_LIST, cv::ContourApproximationModes::CHAIN_APPROX_SIMPLE);
Will OpenCV still able to optimise it using OpenCL even if I am using std::vector? Is there any advantage of using a special container like for example cv::UMat as a container(not an image)?
By tracing OpenCV cv::findContours function, I realized that it is not optimised using OpenCL at all (not CUDA also). The only implementation it has is SSE2 as far as I found in OpenCV 3.1
Related
I am using remap function to undistort openCV image in C++ as following
remap(srcImg, dstImg, map1, map2, INTER_LINEAR, BORDER_CONSTANT);
It takes a lot of time.
Is there is a way I can increase its speed? I tried using Intel remap but did not know how to using with openCV image.
I am trying to make a feature matching algorithm with OpenCV on CUDA.
I am using the ORB features.
The main problem I have is that I am able to well compute the ORB keypoints but the descriptors are always empty. I tried all the ways but without success. I tried with the last version of opencv (3.4.0) and the 3.2.0 version.
This is the simplified version of my code:
cv::Ptr<cv::cuda::ORB> orb_gpu = cv::cuda::ORB::create(5000);
std::vector<cv::KeyPoint> keypoints;
cv::cuda::GpuMat descriptors;
cv::cuda::GpuMat img_gpu(curr_frame);
orb_gpu->detect(img_gpu, keypoints);
orb_gpu->compute(img_gpu, keypoints, descriptors);
cv::Mat desc_cpu;
descriptors.upload(desc_cpu);
The problem is with the direction of memory copy. You are calling upload instead of download function to copy descriptors from device to host. The following line is the culprit:
descriptors.upload(desc_cpu);
Replace it with:
descriptors.download(desc_cpu);
upload copies from host to device whereas download copies from device to host.
I have tested and verified the example with OpenCV 3.4 compiled with CUDA 8 on Ubuntu 14.04.
I'm working on a video stabilisation project using OpenCV, and I've got a CPU implementation working but the performance needs improvement so I'm trying to move most of the processing to the GPU.
The current implementation primarily uses these four OpenCV functions:
cv::goodFeaturesToTrack
cv::calcOpticalFlowPyrLK
cv::estimateRigidTransform
cv::warpAffine
So far I've found the following equivalents on the GPU:
cv::cuda::createGoodFeaturesToTrackDetector
cv::cuda::SparsePyrLKOpticalFlow
cv::cuda::warpAffine
Is there a CUDA equivalent of estimateRigidTransform?
OpenCV doesn't have implementation for estimateRigidTransform on CUDA.
There is opencv based project on github, which has functions for computing homographies and estimating rigid transforms: https://github.com/danielsuo/cuSIFT
Here is function you need:
https://github.com/danielsuo/cuSIFT/blob/master/extras/rigidTransform.cu
There are several OpenCV CPU functions which have a direct CUDA counterpart like cv::cvtColor & cv::cuda::cvtColor.
But I found no direct or indirect (GPU) Cuda counterpart for cv::findContours CPU.
Isn't there a OpenCV Cuda function similar to findContours? Or does findContours work on both cv::Mat and cv::cuda::GpuMat?
Unfortunately, not. Not even in the latest OpenCV 3.2.0 version. But they have this update, as shown here: https://github.com/opencv/opencv/wiki/ChangeLog
findContours can now find contours on a 32-bit integer image of labels (not only on a black-and-white 8-bit image). This is a step towards more convenient connected component analysis.
No. OpenCV 4.6.0 does not have it.
Nobody has dared to implement this with CUDA for years.
I have an input image with 4 circles and I want to use HoughCircles function in OpenCV to identify the circles. I'm using C++ version of OpenCV on a Windows x64 machine. Below is the pseudo-code that I used for circle detection:
Read input image
Convert it from RGB to Gray scale
Gaussian blur
HoughCircles
I tried the above pseudo-code in OpenCV 2.3.1 and OpenCV 3.0. Even though I used the same parameters for Gaussian blur and HoughCircles, OpenCV version2.3.1 identified only 3 circles while version3.0 correctly identified 4 circles. I understand from the changelog that version 3.0 has a new algorithm for HoughCircles but I don't know enough about the method to understand what has changed.
Is the behavior am seeing an expected one? Is HoughCircle detection in OpenCV2.3.1 inferior to that of OpenCV3.0?