Ask Your Question

coldplay's profile - activity

2019-11-16 10:13:29 -0600 received badge  Popular Question (source)
2015-07-30 15:26:28 -0600 commented answer mouse click and draw circle

Ok! I have created my code Code is working, but I have little proplem because My circle function is wrong

    Mat circle_eq(Point2f A,Point2f B,Point2f C)
{
    double W[3][3]={{A.x,A.y,1},
                    {B.x,B.y,1},
                    {C.x,C.y,1}};

    double T[3][1]={-(A.x*A.x+A.y*A.y),
                    -(B.x*B.x+B.y*B.y),
                    -(C.x*C.x+C.y*C.y)};
    Mat M=Mat(3,3,CV_64F,W);
    Mat N=Mat(3,1,CV_64F,T);
    Mat L=M.inv()*N;

    return L;
}

How can I do correctly

2015-07-29 03:38:33 -0600 commented answer mouse click and draw circle

But I want to ask a questions Code is working it is true But I want to draw a lot of circle(7-8) on the same image But code is drawing only one circle What should I do for this problem

2015-07-29 03:29:33 -0600 commented answer mouse click and draw circle

OK! thank you so much

2015-07-29 02:36:54 -0600 received badge  Enthusiast
2015-07-28 15:59:04 -0600 answered a question mouse click and draw circle

Hi I look into given code and I improve my code But I have a problem because I can't declare my variable 'nokta' ANd this is my code

    #include <iostream>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <stdio.h>
#include <iostream>
using namespace std;
using namespace cv;
static int mouse_x = -1;
static int mouse_y = -1;
static int  tik=0;
Mat cember_denklemi(Point2f A,Point2f B,Point2f C)
{
    double W[3][3]={{A.x,A.y,1},
                    {B.x,B.y,1},
                    {C.x,C.y,1}};

    double T[3][1]={-(A.x*A.x+A.y*A.y),
                    -(B.x*B.x+B.y*B.y),
                    -(C.x*C.x+C.y*C.y)};
    Mat M=Mat(3,3,CV_64F,W);
    Mat N=Mat(3,1,CV_64F,T);
    Mat L=M.inv()*N;

    return L;
}
void mouseKordinat(int evt, int x, int y, int flags, void* ptr)
{

if(evt == CV_EVENT_MOUSEMOVE)
  {
    mouse_x = x;
    mouse_y = y;

   tik = tik+1;
  }

}

void getPixelValue(Mat img, int x, int y);
Mat image;

int main()
{
 image = imread("c:/opencv2.4.6./15.jpg");
 imshow("MyWindow", image);
 setMouseCallback("MyWindow", mouseKordinat, 0 );
tik = tik%=3;//burda mod demek istedim3 noktada bir çember çizdirecek ya
int nokta;
if(tik==0)
{   
int merkez=cember_denklemi(nokta(0), nokta(1), nokta(2));
circle(image,merkez,3, Scalar(0,0,255),-1,8, nokta(0));
}
if(tik>3)
{

}
  waitKey(0);
 return 0;
}



void getPixelValue(Mat img, int r, int c)
{
 Vec3b pix=img.at<Vec3b>(r,c);
 int B = pix.val[0];
 int G = pix.val[1];
 int R = pix.val[2];
 cout<<"Row:"<<r<<" "<<"Column:"<<c<<" - "; // mouse kordinatlari
 cout<<"B:"<<B<<" "<<"G:"<<G<<" "<<"R:"<<R<<"\n"; // kordinatın pixel değerleri

}

I wait your helps,Thank you

2015-07-19 13:27:56 -0600 received badge  Supporter (source)
2015-07-19 05:50:39 -0600 asked a question mouse click and draw circle

Hi My topic is draw circle with mouse click method I click 3 points on the image and draw circle I have got a code for drawing circle with given three points but my code is not working this code for draw circel wiht 3 points

    Mat cember_denklemi(Point2f A,Point2f B,Point2f C) {
    double W[3][3]={{A.x,A.y,1},
                    {B.x,B.y,1},
                    {C.x,C.y,1}};

    double T[3][1]={-(A.x*A.x+A.y*A.y),
                    -(B.x*B.x+B.y*B.y),
                    -(C.x*C.x+C.y*C.y)};
    Mat M=Mat(3,3,CV_64F,W);
    Mat N=Mat(3,1,CV_64F,T);
    Mat L=M.inv()*N;

    return L;
}

and this is my code,

    #include <iostream>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <stdio.h>
#include <iostream>
using namespace std;
using namespace cv;
static int mouse_x = -1;
static int mouse_y = -1;
Mat circle_eq(Point2f A,Point2f B,Point2f C)
{
    double W[3][3]={{A.x,A.y,1},
                    {B.x,B.y,1},
                    {C.x,C.y,1}};

    double T[3][1]={-(A.x*A.x+A.y*A.y),
                    -(B.x*B.x+B.y*B.y),
                    -(C.x*C.x+C.y*C.y)};
    Mat M=Mat(3,3,CV_64F,W);
    Mat N=Mat(3,1,CV_64F,T);
    Mat L=M.inv()*N;

    return L;
}
void mouseKordinat(int evt, int x, int y, int flags, void* ptr)
{

if(evt == CV_EVENT_MOUSEMOVE)
  {
    mouse_x = x;
    mouse_y = y;
  }
int tik;
  tik = tik + 1;
}

void getPixelValue(Mat img, int x, int y);
Mat image;

int main()
{
 image = imread("c:/qwz/1q.jpg");
 imshow("MyWindow", image);
 setMouseCallback("MyWindow", mouseKordinat, 0 );
tik = tik%=3;

if(tik==0)
{   
int merkez=circle_eq(nokta(0), nokta(1), nokta(2));
circle(image,merkez,3, Scalar(255,255,255),-1,8, nokta(0));
}
if(tik>3)
{
    int nokta[0][0]=0;


}
  waitKey(0);
 return 0;
}

void mouseKordinat(int evt, int c, int r, int flags, void* ptr)
{
 if(evt==CV_EVENT_LBUTTONDOWN)
 {
 getPixelValue(image,r,c);

 }
}

void getPixelValue(Mat img, int r, int c)
{
 Vec3b pix=img.at<Vec3b>(r,c);
 int B = pix.val[0];
 int G = pix.val[1];
 int R = pix.val[2];
 cout<<"Row:"<<r<<" "<<"Column:"<<c<<" - "; 
 cout<<"B:"<<B<<" "<<"G:"<<G<<" "<<"R:"<<R<<"\n"; 

}