Ask Your Question

Graver's profile - activity

2021-10-28 09:37:18 -0600 received badge  Notable Question (source)
2020-12-04 00:24:07 -0600 received badge  Popular Question (source)
2019-09-29 12:23:14 -0600 received badge  Popular Question (source)
2019-05-18 05:58:01 -0600 received badge  Popular Question (source)
2016-04-01 04:01:51 -0600 commented answer OpenCV CUDA - method that works like inRange()


I need only to detect some squares in a image. The squares are found with canny(). The problem is that i need to binarize a HSV image. I tried to make the sum of the channels but now i have some gray in image.

2016-04-01 02:41:46 -0600 asked a question OpenCV CUDA - method that works like inRange()

I have a image in BGR color space and I convert it in HSV color space. I want to find a method that works on GPU like inRange works on CPU to binarize my image and obtain a threshold. Afer the conversion in HSV colorspace I make a split in three channels. After that I apply threshold() on every channel and finaly call function merge().

The problem is that in the last step i don't get the binary image. The image is colored.

Here is my code

gpu::cvtColor(myFrame_device, myFrameHSV_device, COLOR_BGR2HSV);
gpu::GpuMat channels_device[3];
gpu::GpuMat channels_device_dest[3];
gpu::split(myFrameHSV_device, channels_device);
//Mat myFrameEqualizedHSV(myFrameHSV_device);
//threshold HSV
gpu::threshold(channels_device[0], channels_device_dest[0], 0, 225, THRESH_BINARY);
gpu::threshold(channels_device[1], channels_device_dest[1], 75, 225, THRESH_BINARY);
gpu::threshold(channels_device[2], channels_device_dest[2], 0, 225, THRESH_BINARY);
gpu::merge(channels_device_dest,3, threshold_device);
2016-03-30 03:34:48 -0600 asked a question OpenCV and MFC - strange behaviour of cvGetWindowHandler on 32-bit and 64-bit

I have a MFC project in Microsoft Visual Studio 2010. In my dialog I have a PictureControl. I generate a window with opencv and then i translate it to my PictureControl like this

namedWindow("INPUT", 1);
HWND hWnd = (HWND) cvGetWindowHandle("INPUT");
HWND hParent = ::GetParent(hWnd);
::SetParent(hWnd, GetDlgItem(IDC_BMP_LOAD)->m_hWnd);
::ShowWindow(hParent, SW_HIDE);

When I compile it for 32-bit arhitecture it works. When I compile for 64-bit it generate the namedwindow but doesn't hide and at the name I have a strange string like "%HO", different than "INPUT".

I tried to see if the window handler hWnd is ok and at unsued filed it gives me "CXX0030: Error: expression cannot be evaluated". In documention of OpenCV at the function cvGetWindowHandle() says that it returns a native HWND of the window refered by name in case of Win32 application.

Any help would be appreciated! Thanks.

2016-03-09 07:07:35 -0600 commented question Coordinate transform from ROI in original image

Yes is simple. My problem is that I can't get the offset of the ROI because my ROI was created with RotatedRect. When i try to use locateROI it doesn't gave me the offset. After i get the offset i will make the rotation of points with the angle of RotatedRect "see the code".

2016-03-09 06:12:28 -0600 asked a question Coordinate transform from ROI in original image


I have a little problem with som projection and geometry. I have an image where I detect a square. After the square detection, I crop the square from image. In the ROI I detect the point P(x,y) (see the image below).

image description

My problem is that I know the coordinate of point P in the ROI, the coordinates of A,B,C,D, and rotation of ROI (RotatedRect::angle) but i want to get the coordinate of P in original image. Any advice could help.



For ROI crop I have this code

    vector< RotatedRect > rect(squares.size());

for (int i=0;i<squares.size();i++) // square.size() is the number of detected square(in some cases could be more squares in original image)
    rect[i] = minAreaRect(Mat(squares[i]));
    Mat M,rotated,cropped;
    float angle = rect[i].angle;
    Size rect_size = rect[i].size;

    if (rect[i].angle<-45)
        angle += 90;

    M = getRotationMatrix2D(rect[i].center,angle,1.0);
    SatelliteClass[i].m_vecRect = rect[i];
2016-01-18 08:37:46 -0600 asked a question Convert from GpuMat to Mat

I have a little piece of code that try to convert a Mat to GpuMat and reverse. When I try to upload the Mat in GpuMat with "upload" function, it breaks. If I go next step in the debug the size of GpuMat is written, same as Mat but it doesn't upload the pixel data. Here is the code:

Mat initFrame;
Mat initconv;
Mat threshold;

gpu::GpuMat myFrame;
gpu::GpuMat myFrameLab;


I read that I will need Opencv built with GPU support. Here I don't know what to do. I saw somewhere that in OpenCV directories it exist /gpu/built/... I have 2.4.9 and 3.1 versions but I don't find in Opencv directory the /gpu/build/...

2015-02-15 19:06:40 -0600 commented answer Hough Transform sort output vector

My problem was solved! Just a little adjustemnt at the code (for anybody who looks at this post). The index "i" need to go only to contours.size()/2, beacause if it goes after the nearest_circles_idx will be -1 and will be out of range of the array visited[] and will give an error of "Vector<bool> : iterator not dereferencable".

Thank you very much Guanta for your help!

2015-02-15 12:42:12 -0600 received badge  Scholar (source)
2015-02-15 12:42:10 -0600 commented answer Hough Transform sort output vector

Thanks for help!

2015-02-15 10:10:49 -0600 received badge  Student (source)
2015-02-15 10:03:26 -0600 received badge  Editor (source)
2015-02-15 09:47:25 -0600 asked a question Hough Transform sort output vector


I wrote a code for detcting some circle, but i dont understand how the Hough Transform sort the output.

My program is runing like this

  1. I have six circle that are positioned like this

image description

  1. i need to detect the cirlces and then make de half distance between the ccenters of circles two by two like this

image description

  • the blue dots are the half distances between circles two by two

Now the real example is something like this

For case 1 it works

image description

But when i process a photo like this

image description

Circles are sorted like this :

image description