Ask Your Question

Aqilah's profile - activity

2017-03-02 12:39:31 -0600 commented question How can i increade and decrease the thickness for the Curve openCV

I have two different questions man, that questions is not the same for this. I am trying hard to do this two assignment because i am not good in openCV C++. If you do want to help me. It is okay thanks.

2017-03-02 12:08:13 -0600 asked a question How can i increade and decrease the thickness for the Curve openCV

How can I increase and decrease the thickness for the Curve in openCV

My code can draw like below pictuer:

image description

I want my code to do : show the result by increasing the spline’s thickness and changing the color to blue.

1- ‘I’ or ‘i’ – increase the spline thickness by 1

2- ‘D’ or ‘d’ – decrease the spline thickness by 1

as figure 2

image description

2017-03-02 07:35:38 -0600 asked a question Moving the whole curve to a new location in openCV

My code draws curve correctly, but i need some modify in the code.

what i need is:

user can move a whole spline to a new location. As you may notice, for each, spline, it has a little square in the center area. We call this square as “Editing Region”. As figure 1 shows, when the mouse moves to this region, it turns to green color. It means this spline is highlighted or selected. (Notice: you do NOT need to click the mouse button to highlight the spline. Rather you just need to move the mouse into the square region) Figure 2 shows the highlight result. Once the spline is highlighted, user can drag this spline by mouse left button down and holding it to a new position and releasing the mouse button when the new position is satisfied

figure 1:

image description

figure 2:

image description

My code is below:

2017-03-01 17:09:20 -0600 received badge  Editor (source)
2017-03-01 17:08:34 -0600 asked a question Make some changs in the bezier curve in opencv

I draw a bezier curve by selecting 4 points(MouseEvent) and it works very well. but i want to change the output to be as the picture that i attached

The below picture is the output from my code

image description

I want the the output to be like the below picture (I want the code draw the red line that is connected with the bezier curve )

image description

My code is here


2017-02-06 11:00:23 -0600 commented answer Change the code to make it works on webcam in openCV

Perfect, thanks

2017-02-06 11:00:00 -0600 received badge  Scholar (source)
2017-02-06 09:07:53 -0600 asked a question MouseEvent and draw rectangle in OpenCV

I need some edits. First, the rectangle must be around the selected area (blurring aria) all the time even when i take off my finger from the mouse. Second, i want to change the rectangle type that will be around the blurring aria to be just rectangle that i can see the blurring aria clear because the rectangle that i used, i cant not see blurring aria clear.

This is the code :

include <opencv2 core="" core.hpp="">

include <opencv2 highgui="" highgui.hpp="">

include <opencv2 imgproc="" imgproc.hpp="">

include <iostream>

using namespace std; using namespace cv;

bool selectObject = false; Rect selection; Point origin; int msize = 5; Mat image, blurredImage;

vector<rect> blurredAreas;

static bool doMosaic(Mat img, int msize) {

for (int i = 0; i < img.cols - msize; i += msize)
    for (int j = 0; j < img.rows - msize; j += msize)
    {
        Rect r = Rect(i, j, msize, msize);
        Mat mosaic = img(r);
        mosaic.setTo(mean(mosaic));
    }
return true;

}

static bool doBlur() { for (size_t i = 0; i< blurredAreas.size(); i++) { Mat roi = image(blurredAreas[i]); doMosaic(roi, msize); } imshow("Demo", image); return true; }

static void onMouse(int event, int x, int y, int, void*) { switch (event) { case CV_EVENT_LBUTTONDOWN: origin = Point(x, y); selectObject = true; break; case CV_EVENT_LBUTTONUP: { blurredAreas.push_back(selection); selectObject = false; selection.width = 0; selection.height = 0; break; } }

if (selectObject)
{
    selection.x = MIN(x, origin.x);
    selection.y = MIN(y, origin.y);
    selection.width = std::abs(x - origin.x) + 1;
    selection.height = std::abs(y - origin.y) + 1;
    selection &= Rect(0, 0, image.cols, image.rows);

    if (selection.width > 0 && selection.height > 0)
    {
        Mat roi = image(selection);
        bitwise_not(roi, roi);
    }
}

}

int main(int argc, char** argv) { VideoCapture cap("../data/vtest.avi");

cap >> image;
if (image.empty())                      // Check for invalid input
{
    cout << "Could not open or find the image" << std::endl;
    return -1;
}

namedWindow("Demo");
setMouseCallback("Demo", onMouse);

while (true)
{
    cap >> image;

    if (image.empty())                      // Check for invalid input
    {
        cout << "end." << std::endl;
        return -1;
    }

    if (selection.width > 0 && selection.height > 0)
    {
        Mat roi = image(selection);
        bitwise_not(roi, roi);
    }

    doBlur();

    int key = waitKey(30);

    if (key == 27)
        break;

    if (key == 's') // saves result image
    {
        imwrite("result.jpg", image);
    }

    if (key == 'i') // for increasing mosaic size
    {
        msize += 3;
    }

    if (key == 'd') // key 'd'  for decreasing mosaic size
    {
        msize = msize == 3 ? 3 : msize - 3;
    }

    if (key == 32) // space key for clear blurred areas
    {
        blurredAreas.clear();
    }
}
return 0;

}

2017-02-06 09:01:59 -0600 commented answer Change the code to make it works on webcam in openCV

I sorry, maybe i did not be clear in my question. the updated code is good but i need some edits. First, when LBUTTONU is done , rectangle must be around the selected area (blurring aria) all the time even when i take off my finger from the mouse.. Second, i want to change the rectangle type that will be around the blurring aria to be just rectangle that i can see the blurring aria clear because the rectangle that i used, i cant not see blurring aria clear.

2017-02-06 00:47:29 -0600 asked a question Change the code to make it works on webcam in openCV

I find a code which allows you to draw a blurring rectangle on the image

How can i change it to make it works with webcam

This is my code.

include <opencv2/core/core.hpp>
include <opencv2/highgui/highgui.hpp>
include <opencv2/imgproc/imgproc.hpp>

include <iostream>

using namespace std;
using namespace cv;

bool selectObject = false;
Rect selection;
Point origin;
int msize = 5;
Mat image, blurredImage;

vector<Rect> blurredAreas;

static bool doMosaic(Mat img, int msize)
{

for (int i = 0; i < img.cols - msize; i += msize)
    for (int j = 0; j < img.rows - msize; j += msize)
    {
        Rect r = Rect(i, j, msize, msize);
        Mat mosaic = img(r);
        mosaic.setTo(mean(mosaic));
    }
return true;
}

static bool doBlur()
{
    for (size_t i = 0; i< blurredAreas.size(); i++)
    {
        Mat roi = blurredImage(selection);
        //GaussianBlur(roi,roi,Size(),5,5);
        doMosaic(roi, msize);
    }
    imshow("Demo", blurredImage);
    return true;
}

static void onMouse(int event, int x, int y, int, void*)
{
    switch (event)
    {
    case CV_EVENT_LBUTTONDOWN:
        origin = Point(x, y);
        selectObject = true;
        break;
    case CV_EVENT_LBUTTONUP:
    {
        selectObject = false;
        blurredAreas.push_back(selection);
        doBlur();
        break;
    }
    }

    if (selectObject)
    {
        selection.x = MIN(x, origin.x);
        selection.y = MIN(y, origin.y);
        selection.width = std::abs(x - origin.x) + 1;
        selection.height = std::abs(y - origin.y) + 1;
        selection &= Rect(0, 0, image.cols, image.rows);

        if (selection.width > 0 && selection.height > 0)
        {
            Mat blurredImagecopy;
            blurredImage.copyTo(blurredImagecopy);
            Mat roi = blurredImagecopy(selection);
            bitwise_not(roi, roi);
            imshow("Demo", blurredImagecopy);
        }
    }
}

int main(int argc, char** argv)
{
    image = imread("c:/aa/Adel.png");
    if (image.empty())                      // Check for invalid input
    {
        cout << "Could not open or find the image" << std::endl;
        return -1;
    }
    image.copyTo(blurredImage);

    namedWindow("Demo");
    setMouseCallback("Demo", onMouse);

    imshow("Demo", image);

    while (true)
    {
        int key = waitKey(0);

        if (key == 27)
            break;

        if (key == 's') // saves result image
        {
            imwrite("result.jpg", blurredImage);
        }

        if (key == 'i') // for increasing mosaic size
        {
            msize += 5;
            image.copyTo(blurredImage);
            doBlur();
        }

        if (key == 'd') // key 'd'  for decreasing mosaic size
        {
            msize = msize == 5 ? 5 : msize - 5;
            image.copyTo(blurredImage);
            doBlur();
        }

        if (key == 32) // space key for clear blurred areas
        {
            blurredAreas.clear();
            image.copyTo(blurredImage);
            doBlur();
        }
    }
    return 0;
}