Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please finish the function rotationMat(Point c) attached. //Just copy the following three headers everytime when you use OpenCV #include #include #include #include using namespace cv;
Please finish the function "rotationMat(Point c)" attached. //Just copy the following three headers everytime when you use OpenCV #include#include #include #include using namespace cv; //Use it every time //Tell the compiler, the following codes are all using the "OpenCV" library using namespace std; Mat canvas; //create a white image 1000x800 Point points[1][5]; double angle = 0.0; /*Generate a rotation matrix about "c" and return */ Mat rotationMat(Point c) { Mat rot_mat; //Assign this function return rot_mat; } Point center() { int x_sum = 0; int y_sum = 0; for(int i = 0; i < 5; i++) { x_sum += points[0][i].x; y_sum += points[0][i].y; } Point c = Point(x_sum/5.0, y_sum/5.0); return c; } int main(int argc, char** argv) { canvas.create(800, 1000, CV_8UC3); canvas = Scalar(0, 0, 0); /* Initialize the points */ points[0][0] = Point( 50, 100 ); points[0][1] = Point( 300, 200 ); points[0][2] = Point( 500, 300 ); points[0][3] = Point( 200, 500 ); points[0][4] = Point( 50, 300 ); /* Parameters used by fillPoly */ const Point* ppt[1] = { points[0] }; int npt[] = { 5 }; /* Fill a polygon on the canvas */ fillPoly(canvas, ppt, npt, 1, Scalar( 0, 255, 0 ), LINE_8); Point c = center(); circle(canvas, c, 2, Scalar(0, 0, 255), 2); //show the image on the screen while(1) { imshow("canvas", canvas); char c = waitKey(1); if(c == 27) break; } return 1; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started