박민혀기
20230130 CELLON II Source Code(Rotate Test 추가) 본문
Rotation시 왜곡현상 문제
#include <iostream>
#include "opencv2/opencv.hpp"
using namespace std;
using namespace cv;
int key;
unsigned int Number_of_ROI = 1;
unsigned int Accuracy_Percent = 90;
unsigned int Number_of_ROI_Temp;
unsigned int Accuracy_Percent_Temp;
int flag = 0;
bool Setting_Mode_Flag = false;
bool Config_Flag = false;
unsigned int Compare_Total, Compare_Good, Compare_Bad;
Mat frame, Show_Frame, Inspect_ROI;
vector<Mat> Standard_ROI;
Point temp, temp2;
vector<Point> Inspect_ROI_Point;
vector<Point> State_Message_Point;
vector<String> State_Message_S;
Point Rectangle_Point_x = Point(90, 90);
Point Rectangle_Point_y = Point(165, 90);
Size Rectangle_Size = Size(20, 15);
Point Reset_Button_Point = Point(135, 230);
Size Reset_Button_Size = Point(50, 20);
int button_dis = 30;
double Message_Font_Size = 0.4;
Point Resolution_Point = Point(90, 180);
unsigned int width, height;
Point std_center;
Mat std_gray_img;
const double Rad_to_deg = 57.29;
vector<double> std_angle_list, ins_angle_list;
vector<vector<Point>> std_contours, ins_contours;
Ptr<SimpleBlobDetector> detector;
vector<KeyPoint> std_keypoints, ins_keypoints;
void Image_Draw_Show(int i, Mat *img, Rect rc, Point std_center) {
Mat show_img = *img;
//drawContours(show_img, std_contours, i, Scalar(0, 255, 0), 2, 8);
//rectangle(show_img, rc, Scalar(0, 0, 255), 2, 8);
circle(show_img, std_center, 3, Scalar(0, 255, 0), -1);
drawKeypoints(show_img, std_keypoints, show_img, Scalar(255, 0, 0), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
imshow("std_img", show_img);
}
void ins_Image_Draw_Show(int i, Mat* img, Rect rc, Point std_center) {
Mat show_img = *img;
//drawContours(show_img, std_contours, i, Scalar(0, 255, 0), 2, 8);
//rectangle(show_img, rc, Scalar(0, 0, 255), 2, 8);
circle(show_img, std_center, 3, Scalar(0, 255, 0), -1);
drawKeypoints(show_img, ins_keypoints, show_img, Scalar(255, 0, 0), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
imshow("ins_img", show_img);
}
/////////////Setup SimpleBlobDetector parameters/////////////
void SimpleBlobDetecot_set() {
SimpleBlobDetector::Params params;
//// Change thresholds
//params.minThreshold = 10;
//params.maxThreshold = 200;
//// Filter by Area.
params.filterByArea = true;
params.minArea = 80;
//// Filter by Circularity
//params.filterByCircularity = true;
//params.minCircularity = 0.1;
//// Filter by Convexity
//params.filterByConvexity = true;
//params.minConvexity = 0.87;
//// Filter by Inertia
//params.filterByInertia = true;
//params.minInertiaRatio = 0.01;
detector = SimpleBlobDetector::create(params);
}
///////////////////////Count Segment/////////////////////////
void Default_Set() {
State_Message_Point.clear();
State_Message_Point.push_back(Point(15, height - 125));
State_Message_Point.push_back(Point(15, height - 110));
State_Message_Point.push_back(Point(15, height - 95));
State_Message_Point.push_back(Point(15, height - 80));
State_Message_Point.push_back(Point(15, height - 65));
State_Message_Point.push_back(Point(15, height - 50));
State_Message_Point.push_back(Point(15, height - 35));
State_Message_Point.push_back(Point(15, height - 20));
State_Message_S.push_back(String(" "));
State_Message_S.push_back(String(" "));
State_Message_S.push_back(String(" "));
State_Message_S.push_back(String(" "));
State_Message_S.push_back(String(" "));
State_Message_S.push_back(String(" "));
State_Message_S.push_back(String(" "));
State_Message_S.push_back(String(" "));
}
void State_Message() {
if (State_Message_S[6] != State_Message_S[7]) {
State_Message_S[0] = State_Message_S[1];
State_Message_S[1] = State_Message_S[2];
State_Message_S[2] = State_Message_S[3];
State_Message_S[3] = State_Message_S[4];
State_Message_S[4] = State_Message_S[5];
State_Message_S[5] = State_Message_S[6];
State_Message_S[6] = State_Message_S[7];
}
for (int i = 6; i >= 0; i--) {
putText(Show_Frame, State_Message_S[i], State_Message_Point[i], FONT_HERSHEY_DUPLEX, Message_Font_Size, Scalar(0, 0, 0), 2);
putText(Show_Frame, State_Message_S[i], State_Message_Point[i], FONT_HERSHEY_DUPLEX, Message_Font_Size, Scalar(125, 125, 125), 1);
}
}
void Compare_State(Scalar state_scalar) {
rectangle(Show_Frame, Rect(width - 135, height - 30, 95, 25), Scalar(0, 0, 0), -1);
rectangle(Show_Frame, Rect(width - 130, height - 25, 85, 15), state_scalar, -1);
}
void Compare_Result() {
char Compare_Total_S[15], Compare_Good_S[15], Compare_Bad_S[15];
sprintf_s(Compare_Total_S, "TOTAL : %d", Compare_Total);
sprintf_s(Compare_Good_S, "GOOD : %d", Compare_Good);
sprintf_s(Compare_Bad_S, "BAD : %d", Compare_Bad);
putText(Show_Frame, Compare_Total_S, Point(width - 135, height - 70), FONT_HERSHEY_DUPLEX, 0.5, Scalar(0, 0, 0), 3);
putText(Show_Frame, Compare_Total_S, Point(width - 135, height - 70), FONT_HERSHEY_DUPLEX, 0.5, Scalar(0, 255, 0), 1);
putText(Show_Frame, Compare_Good_S, Point(width - 135, height - 55), FONT_HERSHEY_DUPLEX, 0.5, Scalar(0, 0, 0), 3);
putText(Show_Frame, Compare_Good_S, Point(width - 135, height - 55), FONT_HERSHEY_DUPLEX, 0.5, Scalar(0, 255, 0), 1);
putText(Show_Frame, Compare_Bad_S, Point(width - 135, height - 40), FONT_HERSHEY_DUPLEX, 0.5, Scalar(0, 0, 0), 3);
putText(Show_Frame, Compare_Bad_S, Point(width - 135, height - 40), FONT_HERSHEY_DUPLEX, 0.5, Scalar(0, 255, 0), 1);
}
void ALAM_Marking() {
putText(Show_Frame, "=", Point(14, 42), FONT_HERSHEY_DUPLEX, 1, Scalar(0, 0, 0), 5);
putText(Show_Frame, "CELLON", Point(45, 40), FONT_HERSHEY_DUPLEX, 0.6, Scalar(0, 0, 0), 4);
putText(Show_Frame, "=", Point(14, 42), FONT_HERSHEY_DUPLEX, 1, Scalar(0, 255, 255), 2);
putText(Show_Frame, "CELLON", Point(45, 40), FONT_HERSHEY_DUPLEX, 0.6, Scalar(0, 255, 255), 1);
}
void Center_Marking(double width, double height) {
line(Show_Frame, Point(width / 2, height / 2 + 15), Point(width / 2, height / 2 - 15), Scalar(0, 0, 255), 1);
line(Show_Frame, Point(width / 2 + 15, height / 2), Point(width / 2 - 15, height / 2), Scalar(0, 0, 255), 1);
}
void Setting_Mode() {
char Accuracy_Percent_S[5];
char Number_of_ROI_S[5];
Point Title_Point = Point(5, 102);
Point Value_Point = Point(128, 102);
rectangle(Show_Frame, Rect(Title_Point - Point(2, 30) - Point(3, 3), Title_Point + Point(195, 180) + Point(3, 3)), Scalar(0, 0, 0), -1);
rectangle(Show_Frame, Rect(Title_Point - Point(2, 30), Title_Point + Point(195, 180)), Scalar(125, 125, 125), -1);
sprintf_s(Accuracy_Percent_S, "%d", Accuracy_Percent);
sprintf_s(Number_of_ROI_S, "%d", Number_of_ROI);
putText(Show_Frame, "Accuracy", Title_Point, FONT_HERSHEY_DUPLEX, 0.5, Scalar(0, 0, 0), 3);
putText(Show_Frame, "Accuracy", Title_Point, FONT_HERSHEY_DUPLEX, 0.5, Scalar(255, 255, 255), 1);
putText(Show_Frame, "ROI_Num", Title_Point + Point(0, button_dis), FONT_HERSHEY_DUPLEX, 0.5, Scalar(0, 0, 0), 3);
putText(Show_Frame, "ROI_Num", Title_Point + Point(0, button_dis), FONT_HERSHEY_DUPLEX, 0.5, Scalar(255, 255, 255), 1);
/*//////////////////// +, - Button ////////////////////*/
rectangle(Show_Frame, Rect(Rectangle_Point_x + Point(-3, -3), Rectangle_Size + Size(6, 6)), Scalar(0, 0, 0), -1);
rectangle(Show_Frame, Rect(Rectangle_Point_x + Point(0, button_dis) + Point(-3, -3), Rectangle_Size + Size(6, 6)), Scalar(0, 0, 0), -1);
rectangle(Show_Frame, Rect(Rectangle_Point_x, Rectangle_Size), Scalar(170, 170, 170), -1);
rectangle(Show_Frame, Rect(Rectangle_Point_x + Point(0, button_dis), Rectangle_Size), Scalar(170, 170, 170), -1);
putText(Show_Frame, "-", Rectangle_Point_x + Point(3, 12), FONT_HERSHEY_DUPLEX, 0.5, Scalar(0, 0, 0), 1);
putText(Show_Frame, "-", Rectangle_Point_x + Point(0, button_dis) + Point(3, 12), FONT_HERSHEY_DUPLEX, 0.5, Scalar(0, 0, 0), 1);
rectangle(Show_Frame, Rect(Rectangle_Point_y + Point(-3, -3), Rectangle_Size + Size(6, 6)), Scalar(0, 0, 0), -1);
rectangle(Show_Frame, Rect(Rectangle_Point_y + Point(0, button_dis) + Point(-3, -3), Rectangle_Size + Size(6, 6)), Scalar(0, 0, 0), -1);
rectangle(Show_Frame, Rect(Rectangle_Point_y, Rectangle_Size), Scalar(170, 170, 170), -1);
rectangle(Show_Frame, Rect(Rectangle_Point_y + Point(0, button_dis), Rectangle_Size), Scalar(170, 170, 170), -1);
putText(Show_Frame, "+", Rectangle_Point_y + Point(3, 12), FONT_HERSHEY_DUPLEX, 0.5, Scalar(0, 0, 0), 1);
putText(Show_Frame, "+", Rectangle_Point_y + Point(0, button_dis) + Point(3, 12), FONT_HERSHEY_DUPLEX, 0.5, Scalar(0, 0, 0), 1);
//OK Button
rectangle(Show_Frame, Rect(Resolution_Point - Point(-45, -10 - button_dis - button_dis) + Point(-3, -3),
Reset_Button_Size + Size(6, 6)), Scalar(0, 0, 0), -1);
rectangle(Show_Frame, Rect(Resolution_Point - Point(-45, -10 - button_dis - button_dis), Reset_Button_Size), Scalar(170, 170, 170), -1);
putText(Show_Frame, "OK", Resolution_Point - Point(-55, -25 - button_dis - button_dis), FONT_HERSHEY_DUPLEX, 0.5, Scalar(0, 0, 0), 1);
//Cancel Button
rectangle(Show_Frame, Rect(Resolution_Point - Point(15, -10 - button_dis - button_dis) + Point(-3, -3),
Reset_Button_Size + Size(6, 6)), Scalar(0, 0, 0), -1);
rectangle(Show_Frame, Rect(Resolution_Point - Point(15, -10 - button_dis - button_dis), Reset_Button_Size), Scalar(170, 170, 170), -1);
putText(Show_Frame, "Cancel", Resolution_Point - Point(17, -25 - button_dis - button_dis), FONT_HERSHEY_DUPLEX, 0.5, Scalar(0, 0, 0), 1);
putText(Show_Frame, Accuracy_Percent_S, Value_Point, FONT_HERSHEY_DUPLEX, 0.5, Scalar(0, 0, 0), 3);
putText(Show_Frame, Accuracy_Percent_S, Value_Point, FONT_HERSHEY_DUPLEX, 0.5, Scalar(255, 255, 255), 1);
putText(Show_Frame, Number_of_ROI_S, Value_Point + Point(0, button_dis), FONT_HERSHEY_DUPLEX, 0.5, Scalar(0, 0, 0), 3);
putText(Show_Frame, Number_of_ROI_S, Value_Point + Point(0, button_dis), FONT_HERSHEY_DUPLEX, 0.5, Scalar(255, 255, 255), 1);
//putText(Show_Frame, "0", Value_Point + Point(0, 100), FONT_HERSHEY_DUPLEX, 0.5, Scalar(0, 0, 0), 3);
//putText(Show_Frame, "0", Value_Point + Point(0, 100), FONT_HERSHEY_DUPLEX, 0.5, Scalar(255, 255, 255), 1);
}
void Mouse_Event(int event, int x, int y, int flags, void* userdata) {
if (Setting_Mode_Flag == true && event == EVENT_LBUTTONDOWN) {
if (((Rectangle_Point_x.x <= x) && (Rectangle_Point_x.x + Rectangle_Size.width >= x)) &&
((Rectangle_Point_x.y <= y) && (Rectangle_Point_x.y + Rectangle_Size.height >= y))) { //1-1
if (Accuracy_Percent >= 90) {
Accuracy_Percent--;
}
else {
Accuracy_Percent -= 2;
}
if (Accuracy_Percent == -1 || Accuracy_Percent == -2) {
Accuracy_Percent = 0;
}
}
if (((Rectangle_Point_y.x <= x) && (Rectangle_Point_y.x + Rectangle_Size.width >= x)) &&
((Rectangle_Point_y.y <= y) && (Rectangle_Point_y.y + Rectangle_Size.height >= y))) { //1-2
if (Accuracy_Percent >= 90) {
Accuracy_Percent++;
}
else {
Accuracy_Percent += 2;
}
if (Accuracy_Percent == 101) {
Accuracy_Percent = 100;
}
}
if ((Rectangle_Point_x.x <= x) && (Rectangle_Point_x.x + Rectangle_Size.width >= x) &&
((Rectangle_Point_x.y + button_dis <= y) && (Rectangle_Point_x.y + button_dis + Rectangle_Size.height >= y))) { //2-1
Number_of_ROI--;
if (Number_of_ROI == 0) {
Number_of_ROI = 1;
}
}
if (((Rectangle_Point_y.x <= x) && (Rectangle_Point_y.x + Rectangle_Size.width >= x)) &&
((Rectangle_Point_y.y + button_dis <= y) && (Rectangle_Point_y.y + button_dis + Rectangle_Size.height >= y))) { //2-2
Number_of_ROI++;
if (Number_of_ROI == 6) {
Number_of_ROI = 5;
}
}
if (((Resolution_Point.x - 15 <= x) && (Resolution_Point.x - 15 + Reset_Button_Size.width >= x)) &&
((Resolution_Point.y + 10 + button_dis + button_dis <= y) &&
(Resolution_Point.y + 10 + button_dis + button_dis + Reset_Button_Size.height >= y))) { //Cancel_Button
Number_of_ROI = Number_of_ROI_Temp;
Accuracy_Percent = Accuracy_Percent_Temp;
Setting_Mode_Flag = !Setting_Mode_Flag;
State_Message_S[7] = "Cancel";
State_Message();
if (Inspect_ROI_Point.size() / 2 == Number_of_ROI) {
State_Message_S[7] = "COMPARING_MODE";
flag = -1;
}
else {
State_Message_S[7] = "Cancel";
flag = 0;
}
}
if (((Resolution_Point.x + 45 <= x) && (Resolution_Point.x + 45 + Reset_Button_Size.width >= x)) &&
((Resolution_Point.y + 10 + button_dis + button_dis <= y) &&
(Resolution_Point.y + 10 + button_dis + button_dis + Reset_Button_Size.height >= y))) { //OK_Button
if (Inspect_ROI_Point.size() / 2 != Number_of_ROI) {
Inspect_ROI_Point.clear();
Standard_ROI.clear();
std_angle_list.clear();
flag = 0;
}
else if (Number_of_ROI == Number_of_ROI_Temp && Accuracy_Percent == Accuracy_Percent_Temp) {
Inspect_ROI_Point.clear();
Standard_ROI.clear();
std_angle_list.clear();
flag = 0;
}
else if (Number_of_ROI != Number_of_ROI_Temp && Accuracy_Percent == Accuracy_Percent_Temp) {
Inspect_ROI_Point.clear();
Standard_ROI.clear();
std_angle_list.clear();
flag = 0;
}
else if (Number_of_ROI == Number_of_ROI_Temp && Accuracy_Percent != Accuracy_Percent_Temp) {
flag = -1;
}
else if (Number_of_ROI != Number_of_ROI_Temp && Accuracy_Percent != Accuracy_Percent_Temp) {
Inspect_ROI_Point.clear();
Standard_ROI.clear();
std_angle_list.clear();
flag = 0;
}
Setting_Mode_Flag = !Setting_Mode_Flag;
State_Message_S[7] = "OK";
}
}
////ALAM_MARK////
if (((10 <= x) && (105 >= x)) && ((15 <= y) && (50 >= y)) && event == EVENT_LBUTTONDOWN) {
Setting_Mode_Flag = !Setting_Mode_Flag;
Number_of_ROI_Temp = Number_of_ROI;
Accuracy_Percent_Temp = Accuracy_Percent;
if (Setting_Mode_Flag == false) {
if (Inspect_ROI_Point.size() / 2 == Number_of_ROI) {
State_Message_S[7] = "COMPARING_MODE";
flag = -1;
}
else {
State_Message_S[7] = "POINT_CLICK";
flag = 0;
}
}
else {
State_Message_S[7] = "SETTING_MODE";
flag = 3;
}
}
if (event == EVENT_LBUTTONDBLCLK && (flag == 0 || flag == 1)) {
temp = Point(x, y);
Inspect_ROI_Point.push_back(temp);
State_Message_S[7] = "POINT_CLICK";
flag++;
}
if (flags == EVENT_FLAG_LBUTTON && event == EVENT_MOUSEMOVE && flag == 1) {
rectangle(Show_Frame, Rect(temp, Point(x, y)), Scalar(0, 0, 255), 2);
imshow("Show_Frame", Show_Frame);
}
if (event == EVENT_LBUTTONUP && flag == 1) {
temp2 = Point(x, y);
if (temp2 != temp) {
Inspect_ROI_Point.push_back(temp2);
flag++;
}
else if (temp2 == temp) {
Inspect_ROI_Point.clear();
flag = 0;
}
if (flag == 2) {
if (Inspect_ROI_Point.size() / 2 == Number_of_ROI) {
Config_Flag = true;
flag = -1;
}
else flag = 0;
}
}
}
int main() {
VideoCapture cap("test5.avi");
//VideoCapture cap(0);
if (!cap.isOpened()) {
cout << "Could not find or open Video" << endl;
return 0;
}
width = cap.get(CAP_PROP_FRAME_WIDTH);
height = cap.get(CAP_PROP_FRAME_HEIGHT);
cout << "width : " << width << endl;
cout << "height : " << height << endl;
namedWindow("Show_Frame", WINDOW_AUTOSIZE);
setMouseCallback("Show_Frame", Mouse_Event);
Compare_State(Scalar(0, 255, 255));
Default_Set();
SimpleBlobDetecot_set();
while (1) {
cap >> frame;
if (frame.empty()) break;
Show_Frame = frame.clone();
if (Config_Flag == true) {
for (int i = 0; i < Inspect_ROI_Point.size(); i += 2) {
Standard_ROI.push_back(Mat(frame, Rect(Point(Inspect_ROI_Point[i]),
Point(Inspect_ROI_Point[i + 1]))).clone());
}
std_angle_list.clear();
for (int i = 0; i < Number_of_ROI; i++) {
Mat std_blur_img;
cvtColor(Standard_ROI[i], std_gray_img, COLOR_BGR2GRAY);
blur(std_gray_img, std_blur_img, Size(9, 9));
findContours(std_blur_img, std_contours, RETR_LIST, CHAIN_APPROX_SIMPLE);
for (int i = 0; i < std_contours.size(); i++) {
vector<Point> pnts = std_contours.at(i);
Rect rc = boundingRect(pnts);
if (rc.width > 100 && rc.height > 100) { //배경 흰 색일 경우 rc.width != gray_img.size().width && rc.height != gray_img.size().height 추가
std_gray_img = std_gray_img(rc);
std_center = Point(std_gray_img.cols / 2, std_gray_img.rows / 2);
detector->detect(std_gray_img, std_keypoints);
Point std_point_from_center = Point(std_center.x - std_keypoints[0].pt.x, std_center.y - std_keypoints[0].pt.y);
double std_distance = sqrt(std_point_from_center.x * std_point_from_center.x
+ std_point_from_center.y * std_point_from_center.y);
double std_angle = atan2(std_point_from_center.y, std_point_from_center.x);
std_angle *= Rad_to_deg;
std_angle_list.push_back(std_angle);
Image_Draw_Show(i, &std_gray_img, rc, std_center);
}
}
}
for (int i = 0; i < std_angle_list.size(); i++) {
cout << std_angle_list[i] << endl;
}
Config_Flag = false;
}
if (flag == 1) {
circle(Show_Frame, temp, 2, Scalar(0, 0, 255), -1);
}
else if (flag == -1 && key == 32) {
Mat ins_gray_img, ins_blur_img;
cvtColor(frame, ins_gray_img, COLOR_BGR2GRAY);
blur(ins_gray_img, ins_blur_img, Size(9, 9));
findContours(ins_blur_img, ins_contours, RETR_LIST, CHAIN_APPROX_SIMPLE);
ins_angle_list.clear();
for (int i = 0; i < ins_contours.size(); i++) {
vector<Point> ins_pnts = ins_contours.at(i);
Rect ins_rc = boundingRect(ins_pnts);
if (ins_rc.width > 100 && ins_rc.height > 100) { //배경 흰 색일 경우 rc.width != gray_img.size().width && rc.height != gray_img.size().height 추가
ins_gray_img = ins_gray_img(ins_rc);
Point ins_center = Point(ins_gray_img.cols / 2, ins_gray_img.rows / 2);
detector->detect(ins_gray_img, ins_keypoints);
cout << ins_keypoints.size() << endl;
Point ins_point_from_center = Point(ins_center.x - ins_keypoints[0].pt.x, ins_center.y - ins_keypoints[0].pt.y);
double ins_distance = sqrt(ins_point_from_center.x * ins_point_from_center.x
+ ins_point_from_center.y * ins_point_from_center.y);
double ins_angle = atan2(ins_point_from_center.y, ins_point_from_center.x);
ins_angle *= Rad_to_deg;
ins_angle_list.push_back(ins_angle);
cout << ins_angle << endl;
double betw_angle;
for (int j = 0; j < ins_angle_list.size(); j++) {
betw_angle = std_angle_list[0] - ins_angle_list[j];
cout << "betw_angle : " << betw_angle << endl;
}
Mat rot_mat = getRotationMatrix2D(Point(ins_gray_img.cols / 2, ins_gray_img.rows / 2), -1 * betw_angle, 1.0);
Mat conform_img;
warpAffine(ins_gray_img, conform_img, rot_mat, ins_gray_img.size());
imshow("conform_img", conform_img);
ins_Image_Draw_Show(i, &ins_gray_img, ins_rc, ins_center);
}
}
for (int i = 0; i < Inspect_ROI_Point.size(); i += 2) {
rectangle(Show_Frame, Rect(Point(Inspect_ROI_Point[i]),
Point(Inspect_ROI_Point[i + 1])), Scalar(0, 0, 255), 2);
}
}
else if (flag == -1) {
for (int i = 0; i < Inspect_ROI_Point.size(); i += 2) {
rectangle(Show_Frame, Rect(Point(Inspect_ROI_Point[i]),
Point(Inspect_ROI_Point[i + 1])), Scalar(0, 0, 255), 2);
}
}
else if (flag == 3 && Setting_Mode_Flag == true) {
Setting_Mode();
}
else if (flag == 0) {
for (int i = 0; i < Inspect_ROI_Point.size(); i += 2) {
rectangle(Show_Frame, Rect(Point(Inspect_ROI_Point[i]),
Point(Inspect_ROI_Point[i + 1])), Scalar(0, 0, 255), 2);
}
}
State_Message();
ALAM_Marking();
Compare_Result();
Compare_State(Scalar(0, 255, 255));
imshow("Show_Frame", Show_Frame);
key = waitKey(33);
if (key == 27) {
break;
}
}
return 0;
}
Rotate Test Source Code
#pragma comment(lib, "opencv_world453.lib")
#pragma comment(lib, "opencv_world453d.lib")
#include <iostream>
#include "opencv2/opencv.hpp"
using namespace std;
using namespace cv;
int main() {
VideoCapture cap("CELLON II Sample VIdeo\\test5.avi");
//VideoCapture cap(0);
if (!cap.isOpened()) {
cout << "Could not find or open Video" << endl;
return 0;
}
Mat frame, Rotate_Frame;
while (1) {
cap >> frame;
if (frame.empty()) break;
Mat rot_mat = getRotationMatrix2D(Point(frame.cols / 2, frame.rows / 2), 45, 1.0);
warpAffine(frame, Rotate_Frame, rot_mat, frame.size());
imshow("Rotate_Frame", Rotate_Frame);
imshow("frame", frame);
if (waitKey(33) == 27) break;
}
return 0;
}
'CELLON II > Source Code' 카테고리의 다른 글
20230207 CELLON II(All Source Code, Ref) (0) | 2023.02.07 |
---|---|
20230125 CELLON Source Code (0) | 2023.01.25 |
CELLON II 프로젝트(이미지 회전) (0) | 2023.01.11 |