Ask Your Question

brycemh's profile - activity

2020-10-11 03:03:56 -0600 received badge  Famous Question (source)
2018-06-11 14:10:28 -0600 received badge  Notable Question (source)
2017-10-31 14:03:12 -0600 received badge  Popular Question (source)
2014-07-14 10:41:19 -0600 asked a question Changing line colors randomly.

Hello all, I wrote a code that draws a line for every nth degree. I need to know how to create another loop that will change the color of every line. I have researched RNG and things of that nature, but nothing is working for me. Please help or give me tips if you can; below is my code.

    int x = shape->width;
    int y = shape->height;
    int m = 0;
    int l = 2;
    int q = 200;
    int z = shape->width / l;
    int a = shape->height / l;
    int b = 10;
    int f = -255;
    int g = 255;
    int w = 450;
    int v = 36;
    int h = 100;
    int p = l++;
    int r = 10;
    int s = r++;
    int t = 30;
    int u = t++;
    int c = 150;


    cvRectangle(shape,cvPoint(x,m),cvPoint(m,y),CV_RGB(m,g,m),f,g);

    //Drawing a Circle
    cvCircle(shape,cvPoint(z,a),q, CV_RGB(m,m,g),f);

    // for loop execution 
    for(int o = c; o < 511; o+=v){ 
    for(int n = c; n < 467; n+=v){ 
        cvLine(shape, cvPoint(z,a), cvPoint(o,n), CV_RGB(p,r,u),1,1);   
        }
    }

    cvCircle(shape,cvPoint(z,a),b,CV_RGB(m,g,m),f);
    cvCircle(shape,cvPoint(z,a),q, CV_RGB(g,m,m),h,g);
    //Showing the image
    cvShowImage("Shapes",shape);
    //Escape Sequence
    cvWaitKey(0);
    //CleanUp
    cvReleaseImage(&shape);
    cvDestroyAllWindows();

}
2014-07-11 07:25:04 -0600 asked a question For Loop Code Issues, please help adjust code

Below is a copy of my for loop code, it is supposed to draw lines around a circle. The radius is 150. It is supposed to draw a line for every 36th degree and the point I found that goes from the center of the circle to the edge of the circle is (242.7,176.3). The image is 600x600 and the circle's center is (300,300). Below is the code and an image of what happens when i run the code. Please help if you can.

int x = shape->width;
int y = shape->height;
int m = 0;
int l = 2;
int q = 140;
int z = shape->width / l;
int a = shape->height / l;
int b = 10;
int f = -255;
int g = 255;


cvRectangle(shape,cvPoint(x,m),cvPoint(m,y),CV_RGB(m,g,m),f,g);

//Drawing a Circle
cvCircle(shape,cvPoint(z,a),q,CV_RGB(m,m,g),f);
cvCircle(shape,cvPoint(z,a),b,CV_RGB(m,g,m),f);

// for loop execution 
for(int o = 242.7; o < 450; o+=36){ 
    for(int n = 176.3; n < 450; n+=36){ 
        cvLine(shape, cvPoint(z,a), cvPoint(o,n), CV_RGB(255,0,0),1,8); 
    }
}

image description

2014-07-11 06:45:27 -0600 commented answer Finding a point on a circle?

@BalajiRenganathan I figured it out, but I have a question; how will I use this point to create a loop that will draw a line from the center to the edge of a circle? example: I have the radius (150), the point on the circle (242.7,176.3) , and the degree (36), how can I draw a line for every 36th degree?

2014-07-11 06:11:57 -0600 commented answer Finding a point on a circle?

@BalajiRenganathan I tried using the answer you gave, but it didn't work, it gave me a few error messages after I changed some of the values.

2014-07-10 13:21:36 -0600 commented answer Please tell me what's wrong with my code! New OpenCV User

@unxnut how do I find the distance between these two points?

2014-07-10 11:18:32 -0600 commented question Please tell me what's wrong with my code! New OpenCV User

The dimensions of the image are 600 x 600.

2014-07-10 11:17:56 -0600 asked a question Please tell me what's wrong with my code! New OpenCV User

Below is my code. It is supposed to draw lines from the center of the circle to the edge of the circle, but some of the lines are too short while others are too long. Does anyone have a fix for this?

cvNamedWindow("Shapes",CV_WINDOW_AUTOSIZE);
//Image structure
IplImage* shape=cvLoadImage("white2.jpg");

//Drawing a Rectangle
int x = shape->width;
int y = shape->height;
int m = 0;
int l = 2;
int q = 300;
int z = shape->width / l;
int a = shape->height / l;
int b = 10;
int f = -255;
int g = 255;

cvRectangle(shape,cvPoint(x,m),cvPoint(m,y),CV_RGB(m,g,m),f,g);

//Drawing a Circle
cvCircle(shape,cvPoint(z,a),q,CV_RGB(m,m,g),f);
cvCircle(shape,cvPoint(z,a),b,CV_RGB(m,g,m),f);




for(int o = 2; o < 800; o+=45){
for(int n = 2; n < 800; n +=45){
    cvLine(shape, cvPoint(z,a), cvPoint(o,n), CV_RGB(0,255,0),1,8);     
    }
}

//Showing the image
cvShowImage("Shapes",shape);
//Escape Sequence
cvWaitKey(0);
//CleanUp
cvReleaseImage(&shape);
cvDestroyAllWindows();

}

2014-07-10 06:38:40 -0600 asked a question Please help! New to OpenCV: Loops

Good morning guys,

I am new to OpenCV and I need a little help with a programming practice assignment; how can I create a for loop that will draw a line from the center of a circle to the edge of the circle? For example, how can I create a loop that will draw a line for every 30 degrees from the center of a circle to the edge of a circle or something of that nature. Please help if you can, I have been stuck for two days now!

Thanks in advance!

2014-07-09 08:15:43 -0600 asked a question Finding a point on a circle?

Hey guys,

I am trying to create a code that will draw a line for every nth degree around the center point of a circle (like a clock). Does anyone know how to go about doing this?

Thanks!

2014-07-07 06:42:08 -0600 asked a question How to save an image from OpenCV

Hey guys,

I wanted to know if there is a function that will allow me to save an image from opencv; for example, i wrote a program that will rotate an image 90 degrees. How can I save the rotated image to a folder?

Thanks

2014-07-03 12:33:05 -0600 commented answer HELP PLEASE? Image window will not open.

@hadoofi Thank you alot! I don't quite understand the loops though; if possible, can you explain? I am new to OpenCV and C++.

2014-07-03 12:31:55 -0600 received badge  Scholar (source)
2014-07-03 12:31:50 -0600 received badge  Supporter (source)
2014-07-03 10:58:51 -0600 commented answer HELP PLEASE? Image window will not open.

@hadoofi I am trying to draw vertical and horizontal lines for every 5th pixel on my image. Any more help you can give me?

2014-07-03 10:08:51 -0600 asked a question HELP PLEASE? Image window will not open.

BELOW IS A COPY OF MY CODE. IT BUILDS SUCCESSFULLY, BUT WHEN I RUN THE PROGRAM, THE IMAGE WINDOW WILL NOT OPEN image description

2014-07-03 10:02:41 -0600 asked a question HELP PLEASE?! Image won't open for programming assignment!

BELOW IS MY PROGRAM; THE PROGRAM BUILDS SUCCESSFULLY, BUT MY IMAGE WON'T OPEN WHEN I TRY TO RUN THE PROGRAM! PLEASE HELP ME!

include "opencv2/highgui/highgui.hpp"

include <iostream>

using namespace cv; using namespace std;

int main() { cvNamedWindow("MyWindow",CV_WINDOW_AUTOSIZE); Mat img = imread("dm.jpg", CV_LOAD_IMAGE_UNCHANGED);

//for loop execution
int x; 
int y = 367;
int z = 0;

for (int x=0; x<=367; x = x+5)
{
    return line(img, cvPoint(x,y), cvPoint(x,z), CV_RGB(255,255,255),10,8);
}
int a;
for (a=0, a <= 367; a=a+5;)
{
    return line(img,cvPoint(a,y),cvPoint(a,z),CV_RGB(0,0,0),10,8);
}

     namedWindow("MyWindow", CV_WINDOW_AUTOSIZE); //create a window with the name "MyWindow"
 imshow("MyWindow", img); //display the image which is stored in the 'img' in the "MyWindow" window

}

2014-07-03 09:58:15 -0600 received badge  Critic (source)
2014-04-16 19:50:47 -0600 asked a question Help! Installation of OpenCV

I am new to OpenCV; I have to download it for a summer computer science assignment. I do not have Microsoft Visual Studio and I am having a very hard time installing OpenCV. I watched the installation videos on this website, but still no luck. Can anyone please tell me how to install openCV successfully? Thanks in advance!