Ask Your Question

Noxalus's profile - activity

2015-05-28 04:52:09 -0600 commented question Multiple circles with a single call to cv::circle function

Thanks for your help, I finally figured out what happen, and it's my entire fault...

When you create a new Mat you need to pass it the image's height as first argument, and not width. The circle is drawn properly if I switch the arguments.

2015-05-26 12:15:42 -0600 commented question Multiple circles with a single call to cv::circle function

I just tried to change radius argument type, but it didn't change anything. I don't really see what is the problem neither :'(

I don't know if it can help, but I have a weird behaviour too when I use GaussianBlur function, the original image is cut in 4 parts for no apparent reason... (code) (image)

2015-05-26 11:44:01 -0600 commented question Multiple circles with a single call to cv::circle function

@Lorena GdL: I think I can't use imshow because I'm on iPad and it doesn't seem to be implemented for this platform.

But if it's a problem further, why the image captured from the iPad's camera is correct? I also tried to draw a blue square on my image doing something like that:

for(auto i = 0; i < (width * height) * 4; i += 4)
{
    auto x = (i / 4) % width;
    auto y = (i / 4) / width;

    if ((x >= (width / 2.f) - 100 && x <= (width / 2.f) + 100) ||
      (y >= (height / 2.f) - 100 && y <= (height / 2.f) + 100))
    {
      src.data[i] = (char)255;
    }
}

And the square is drawn properly. This is why it lets me think that my output is correct.

2015-05-26 11:11:50 -0600 commented question Multiple circles with a single call to cv::circle function

Thank you very well for your help. To answer to your questions, I tried a simple version of the code above => here for the code

What I got is not better :'( (image)

PS: proccessImage is called each time we receive a new frame from the iPad's camera.

2015-05-26 10:47:13 -0600 commented question Multiple circles with a single call to cv::circle function

Thanks for your answer thdrksdfthmn. I already read the documentation of circle function => "The function circle draws a simple or filled circle with a given center and radius."

So why do I have many circles drawn whereas I only called circle function once?

2015-05-26 10:12:33 -0600 asked a question Multiple circles with a single call to cv::circle function

Hello everyone.

I'm new with OpenCV library, and I would like to use it to detect circle in a video stream captured from an iPad back camera. I figured out how to do it and with OpenCV, it can be done in less than 10 lines of code. But it doesn't work for me, and I think I missed something because of some weird behaviours I obtain.

Here is a very simple code that doesn't work:

void proccessImage(std::vector<unsigned char>& imageData, int width, int height)
{
    // Create cv::Mat from std::vector<unsigned char>
    Mat src(width, height, CV_8UC4, const_cast<unsigned char*>(imageData.data()));
    Mat src_gray;
    Mat final;

    // Convert the original image from BGRA to gray
    cvtColor(src, src_gray, CV_BGRA2GRAY);

    // Draw a circle at position (300, 200) with a radius of 30
    cv::Point center(300, 200);
    circle(src_gray, center, 30.f, Scalar(0,0,255, 255), 3, 8, 0);

    // Convert the gray image to RGBA
    cvtColor(src_gray, final, CV_GRAY2RGBA);

    // Reform the std::vector from cv::Mat data
    std::vector<unsigned char> array;
    array.assign((unsigned char*)final.datastart, (unsigned char*)final.dataend);

    // Send final image data to GPU and draw it
}

For me, this should convert the image in gray and draw a simple circle at the specified position. But instead of that, I get this:

image description

[the data from the iPad's back camera is correct and is gray, but the circle is drawn multiple times with weird stripes]

Do you know what happened?