Skip to content

Commit

Permalink
* fix run 1-1 wrong, the reason is the multi thread condition.
Browse files Browse the repository at this point in the history
  • Loading branch information
liuruoze committed Jul 5, 2016
1 parent fffb964 commit a1045d1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion include/easypr/core/plate_locate.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class CPlateLocate {


int colorSearch(const Mat& src, const Color r, Mat& out,
std::vector<RotatedRect>& outRects, int index = 0);
std::vector<RotatedRect>& outRects);

int mserSearch(const Mat &src, vector<Mat>& out,
vector<vector<CPlate>>& out_plateVec, bool usePlateMser, vector<vector<RotatedRect>>& out_plateRRect,
Expand Down
Binary file added resources/image/test.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 14 additions & 12 deletions src/core/plate_locate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ int CPlateLocate::mserSearch(const Mat &src, vector<Mat> &out,


int CPlateLocate::colorSearch(const Mat &src, const Color r, Mat &out,
vector<RotatedRect> &outRects, int index) {
vector<RotatedRect> &outRects) {
Mat match_grey;

// width is important to the final results;
Expand All @@ -118,9 +118,9 @@ int CPlateLocate::colorSearch(const Mat &src, const Color r, Mat &out,

colorMatch(src, match_grey, r, false);

if (m_debug) {
utils::imwrite("resources/image/tmp/match_grey.jpg", match_grey);
}
//if (m_debug) {
// utils::imwrite("resources/image/tmp/match_grey.jpg", match_grey);
//}

Mat src_threshold;
threshold(match_grey, src_threshold, 0, 255,
Expand All @@ -130,9 +130,9 @@ int CPlateLocate::colorSearch(const Mat &src, const Color r, Mat &out,
MORPH_RECT, Size(color_morph_width, color_morph_height));
morphologyEx(src_threshold, src_threshold, MORPH_CLOSE, element);

if (m_debug) {
utils::imwrite("resources/image/tmp/color.jpg", src_threshold);
}
//if (m_debug) {
// utils::imwrite("resources/image/tmp/color.jpg", src_threshold);
//}

src_threshold.copyTo(out);

Expand Down Expand Up @@ -722,19 +722,21 @@ int CPlateLocate::plateColorLocate(Mat src, vector<CPlate> &candPlates,
vector<CPlate> plates_yellow;
plates_yellow.reserve(64);

Mat src_clone = src.clone();

Mat src_b_blue;
Mat src_b_yellow;
#pragma omp parallel sections
{
#pragma omp section
{
Mat src_b_blue;
colorSearch(src, BLUE, src_b_blue, rects_color_blue, index);
colorSearch(src, BLUE, src_b_blue, rects_color_blue);
deskew(src, src_b_blue, rects_color_blue, plates_blue, true, BLUE);
}
#pragma omp section
{
Mat src_b_yellow;
colorSearch(src, YELLOW, src_b_yellow, rects_color_yellow, index);
deskew(src, src_b_yellow, rects_color_yellow, plates_yellow, true, YELLOW);
colorSearch(src_clone, YELLOW, src_b_yellow, rects_color_yellow);
deskew(src_clone, src_b_yellow, rects_color_yellow, plates_yellow, true, YELLOW);
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/plate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ int test_plate_locate() {

vector<cv::Mat> resultVec;
CPlateLocate plate;
plate.setDebug(1);
plate.setLifemode(true);
//plate.setDebug(0);
//plate.setLifemode(true);

int result = plate.plateLocate(src, resultVec);
if (result == 0) {
Expand Down

0 comments on commit a1045d1

Please sign in to comment.