energy changed

This commit is contained in:
sun
2019-07-30 05:29:18 +08:00
parent 49240ec1bf
commit b253c47283
2 changed files with 23 additions and 7 deletions

View File

@@ -14,7 +14,10 @@ using std::vector;
// 此函数用于寻找图像内所有的大风车扇叶 // 此函数用于寻找图像内所有的大风车扇叶
// --------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------------
int Energy::findFans(const cv::Mat src) { int Energy::findFans(const cv::Mat src) {
if (src.empty())return 0; if (src.empty()){
cout << "empty!" << endl;
return 0;
}
static Mat src_bin; static Mat src_bin;
src_bin = src.clone(); src_bin = src.clone();
if (src.type() == CV_8UC3) { if (src.type() == CV_8UC3) {
@@ -59,7 +62,10 @@ int Energy::findFans(const cv::Mat src) {
// 此函数用于寻找图像内所有的大风车装甲板模块 // 此函数用于寻找图像内所有的大风车装甲板模块
// --------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------------
int Energy::findArmors(const cv::Mat src) { int Energy::findArmors(const cv::Mat src) {
if (src.empty())return 0; if (src.empty()){
cout << "empty!" << endl;
return 0;
}
static Mat src_bin; static Mat src_bin;
src_bin = src.clone(); src_bin = src.clone();
if (src.type() == CV_8UC3) { if (src.type() == CV_8UC3) {
@@ -114,7 +120,10 @@ int Energy::findArmors(const cv::Mat src) {
// 此函数用于寻找图像内大风车中心字母“R” // 此函数用于寻找图像内大风车中心字母“R”
// --------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------------
bool Energy::findCenterR(const cv::Mat src) { bool Energy::findCenterR(const cv::Mat src) {
if (src.empty())return false; if (src.empty()){
cout << "empty!" << endl;
return false;
}
static Mat src_bin; static Mat src_bin;
src_bin = src.clone(); src_bin = src.clone();
if (src.type() == CV_8UC3) { if (src.type() == CV_8UC3) {
@@ -163,7 +172,10 @@ bool Energy::findCenterR(const cv::Mat src) {
// 此函数用于判断找到的矩形候选区是否为含流动条的扇叶 // 此函数用于判断找到的矩形候选区是否为含流动条的扇叶
// --------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------------
bool Energy::findFlowStripFan(const cv::Mat src) { bool Energy::findFlowStripFan(const cv::Mat src) {
if (src.empty())return false; if (src.empty()){
cout << "empty!" << endl;
return false;
}
static Mat src_bin; static Mat src_bin;
static Mat src_copy; static Mat src_copy;
src_bin = src.clone(); src_bin = src.clone();
@@ -201,9 +213,8 @@ bool Energy::findFlowStripFan(const cv::Mat src) {
if (flow_strip_fans.empty()) { if (flow_strip_fans.empty()) {
if (show_info)cout << "flow strip fan false!" << endl; if (show_info)cout << "flow strip fan false!" << endl;
return false; return false;
} else {
return true;
} }
return true;
} }
@@ -211,7 +222,10 @@ bool Energy::findFlowStripFan(const cv::Mat src) {
// 此函数用于寻找流动条 // 此函数用于寻找流动条
// --------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------------
bool Energy::findFlowStrip(const cv::Mat src) { bool Energy::findFlowStrip(const cv::Mat src) {
if (src.empty())return false; if (src.empty()) {
cout << "empty!" << endl;
return false;
}
cv::Mat src_bin; cv::Mat src_bin;
src_bin = src.clone(); src_bin = src.clone();
@@ -296,6 +310,7 @@ bool Energy::findFlowStrip(const cv::Mat src) {
} }
} }
} }
return true;
} }

View File

@@ -165,6 +165,7 @@ void Energy::showFlowStripFan(std::string windows_name, const cv::Mat src) {
center_ROI.points(ROI_vertices); //计算矩形的4个顶点 center_ROI.points(ROI_vertices); //计算矩形的4个顶点
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
line(image2show, ROI_vertices[i], ROI_vertices[(i + 1) % 4], Scalar(0, 0, 255), 2); line(image2show, ROI_vertices[i], ROI_vertices[(i + 1) % 4], Scalar(0, 0, 255), 2);
cout<<"show strip!"<<endl;
imshow(windows_name, image2show); imshow(windows_name, image2show);
} }