Getting coordinates for perspective transform using mousecallback() [closed]
I tried the following code for perspective transform
#include "opencv2/opencv.hpp"
#include<iostream>
using namespace cv;
using namespace std;
int ival(int x, int y);
void coordinate(int event, int x, int y, int flags, void* temp)
{
int check;
if ( event == EVENT_LBUTTONDOWN && flags==EVENT_FLAG_CTRLKEY)
{
check=ival(x,y);
if(check=0)
return;
}
}
vector<Point2f> P,Q;
int main()
{
Mat ocv = imread("E:\\Tennis.jpg");
namedWindow("Input");
imshow("input",ocv);
setMouseCallback("Input", coordinate,NULL );
Q.push_back(Point2f(10,10)); // 10 pixel border on all sides
Q.push_back(Point2f(210,10));
Q.push_back(Point2f(210,210));
Q.push_back(Point2f(10,210));
Mat rot = cv::getPerspectiveTransform(P,Q);
Mat result;
cv::warpPerspective(ocv, result, rot, Size(220,220));
imshow("result",result);
waitKey();
return 0;
}
I tried to get the coordinates of the source object for transform with mousecallback() but i cant able to achieve it Please tell me the logic to get four co-ordinate points using mousecallback function?
Where is your problem? How does your current mouse callback look like? Showing that you invested some time to solve the problem always improves the motivation to help...
@FooBar I edited the question with my program. There is somewhere logic is missing. I cant figure it out.