Issue 1:
Transferred from http://code.opencv.org/issues/2461

|| Walter Blume on 2012-10-19 17:20
|| Priority: Normal
|| Affected: None
|| Category: imgproc, video
|| Tracker: Bug
|| Difficulty: None
|| PR: None
|| Platform: None / None

hough circle detection not symmetric, misses obvious circle

For some reason the Hough circle detection misses an obvious circle, but if I flip the image, the circle is detected. One would think that results would be similar with flipped image, but they are not.

Attached is source code and test input image that exhibited the problem. Also screenshot with arrow showing the obvious circle miss.

Using OpenCV 2.4.2, built with TBB on Windows7 64 bit machine

History

Daniil Osokin on 2012-10-22 06:34

Thank you, we will check it.
- Category set to imgproc, video

Jason Harper on 2014-02-22 23:04

The problem is in the non-maxima suppression. It is only checking if a value that passes the threshold is also larger (but not equal) than all of it's neighbors. In the first case there are two pixels with equal values next to each other. When that happens neither pixel is set as a possible center and the circle is ignored. When the image is flipped one of these pixels gets an extra count leaving a single peak which gets labeled as a possible center.

I changed the check to >= and it fixed the problem and will submit a pull request soon.

leonardo bocchi on 2015-06-01 15:59

I faced the same problem, and found the same solution.
To avoid duplication, I changed lines 1112-1113 of hough.cpp to read:

adata[base] >= adata[base-1] && adata[base] > adata[base+1] &&
adata[base] >= adata[base-acols-2] && adata[base] > adata[base+acols+2] )

It seems working and no duplicate detections.

Issue 2:
System information (version)

OpenCV => 4.0.0

Operating System / Platform => Ubuntu 16.04

GPU => NVIDIA GeForce GTX 1080

Detailed description

As I read the changelog for opencv 4.0.0 the dnn module option setPreferableTarget(DNN_TARGET_OPENCL) was fixed.

For this, I installed and test the version 4.0.0 and test that openCL backend is using my gpu. But, when I run my code with this option the code is still running on cpu. I looked htop with and without ````setPreferableTarget``` and both ways load the cpu equals. Also, measure time and it is the same for both ways. For this I searched about openCL and check that Opencv is really using my gpu. When I run

std::vector< cv::ocl::PlatformInfo > platform_info;
if (!cv::ocl::haveOpenCL())
{
cout << "OpenCL is not available..." << endl;
//return;
}
cv::ocl::setUseOpenCL(true);
ocl::getPlatfomsInfo(platform_info);

for(int i = 0; i < platform_info.size(); i++){
ocl::PlatformInfo sdk = platform_info.at(i);
for (int j = 0; j < sdk.deviceNumber(); j++) {
ocl::Device device;
sdk.getDevice(device, j);

cout << "\n\n*********************\n Device " << i + 1 << endl;
cout << "Vendor ID: " << device.vendorID() << endl;
cout << "Vendor name: " << device.vendorName() << endl;
cout << "Name: " << device.name() << endl;
cout << "Driver version: " << device.driverVersion() << endl;
cout << "available: " << device.available() << endl;

if (device.isAMD()) cout << "Is an AMD device" << endl;
if (device.isIntel()) cout << "Is a Intel device" << endl;

cout << "Global Memory size: " << device.globalMemSize() << endl;
cout << "Memory cache size: " << device.globalMemCacheSize() << endl;
cout << "Memory cache type: " << device.globalMemCacheType() << endl;
cout << "Local Memory size: " << device.localMemSize() << endl;
cout << "Local Memory type: " << device.localMemType() << endl;
cout << "Max Clock frequency: " << device.maxClockFrequency() << endl;

}
}

output is:

*********************
Device 1
Vendor ID: 2
Vendor name: Intel(R) Corporation
Name: Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
Driver version: 1.2.0.37
available: 1
Is a Intel device
Global Memory size: 16782102528
Memory cache size: 262144
Memory cache type: 2
Local Memory size: 32768
Local Memory type: 2
Max Clock frequency: 3400

*********************
Device 2
Vendor ID: 3
Vendor name: NVIDIA Corporation
Name: GeForce GTX 1080
Driver version: 384.130
available: 1
Global Memory size: 8499691520
Memory cache size: 327680
Memory cache type: 2
Local Memory size: 49152
Local Memory type: 1
Max Clock frequency: 1733

OpenCL detect the gpu, this is good. But when run this,

cv::ocl::Context context;
if (!context.create(cv::ocl::Device::TYPE_ALL))
{
cout << "Failed creating the context..." << endl;
//return;
}
cout << "**********************"<<endl;
cout << context.ndevices() << " GPU devices are detected." << endl; //This bit provides an overview of the OpenCL devices you have in your computer
for (int i = 0; i < context.ndevices(); i++)
{
cv::ocl::Device device = context.device(i);
cout << "name: " << device.name() << endl;
cout << "available: " << device.available() << endl;
cout << "imageSupport: " << device.imageSupport() << endl;
cout << "OpenCL_C_Version: " << device.OpenCL_C_Version() << endl;
cout << endl;
}

In the output only detect the intel gpu.

**********************
1 GPU devices are detected.
name: Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
available: 1
imageSupport: 1
OpenCL_C_Version: OpenCL C 2.0

I don't know how to set openCL for use Nvidia Gpu and after that check if dnnTarget is using it in forward.

Steps to reproduce