Skip to content

Commit

Permalink
Merge pull request #2 from seyfu-t/master
Browse files Browse the repository at this point in the history
updated OpenCV functions to be compatible with API changes made in later versions
  • Loading branch information
iyyun authored Sep 2, 2024
2 parents e95a3bc + 1d77926 commit 7c2ae70
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Settings
.vscode/

# Prerequisites
*.d

Expand All @@ -6,6 +9,7 @@
*.lo
*.o
*.obj
build/

# Precompiled Headers
*.gch
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ This is a barcode detection project at the digital signal processing laboratory
The software runs under windows and linux and is written in C++.

Based on the following libraries:
* OpenCV ( >= 3.1)
* OpenCV ( >= 4.10)
* CMake (>= 2.8)
* VTK (>= 9.3.1)
* HDF5 (>= 1.14.4.3)

Build Instructions
------------------
Expand Down
2 changes: 1 addition & 1 deletion src/Linux/tencon/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.5)

project( iyCode )

Expand Down
8 changes: 4 additions & 4 deletions src/Linux/tencon/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ int main(int argc, char* argv[])
return -1;
}

cv::cvtColor(frame, frame_gray, CV_BGR2GRAY);
cv::cvtColor(frame, frame_gray, cv::COLOR_BGR2GRAY);

cv::Rect g_rt = mGallo.process(frame_gray, 20);
cv::rectangle(frame, g_rt, cvScalar(0, 255, 0), 2);
cv::rectangle(frame, g_rt, cv::Scalar(0, 255, 0), 2);

cv::Rect s_rt = mSoros.process(frame_gray, 20);
cv::rectangle(frame, s_rt, cvScalar(255,0,0), 2);
cv::rectangle(frame, s_rt, cv::Scalar(255,0,0), 2);

std::vector<iy::YunCandidate> list_barcode = mYun.process(frame_gray);
if (!list_barcode.empty())
Expand All @@ -51,7 +51,7 @@ int main(int argc, char* argv[])
if (it->isBarcode)
{
cv::Rect y_rt = it->roi;
cv::rectangle(frame, y_rt, cvScalar(0, 255, 255), 2);
cv::rectangle(frame, y_rt, cv::Scalar(0, 255, 255), 2);
}
}

Expand Down
22 changes: 11 additions & 11 deletions src/Linux/tencon/yun/yun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ std::vector<YunLabel> Yun::ccl(cv::Mat &src, cv::Mat &oMap, std::vector<YunOrien
//
r = h;
c = w;
rect = cvRect(w, h, 0, 0);
rect = cv::Rect(w, h, 0, 0);

top = 0;
++label_id; if (label_id > 255) label_id = 1;
Expand All @@ -315,8 +315,8 @@ std::vector<YunLabel> Yun::ccl(cv::Mat &src, cv::Mat &oMap, std::vector<YunOrien
{
for (int n = c - 1; n <= c + 1; n++)
{
if ((m < 0) || (m >= imSz.height)) continue; // height ¹üÀ§ ÇÑÁ¤
if ((n < 0) || (n >= imSz.width)) continue; // width ¹üÀ§ ÇÑÁ¤
if ((m < 0) || (m >= imSz.height)) continue; // height ���� ����
if ((n < 0) || (n >= imSz.width)) continue; // width ���� ����

if (mask.at<uchar>(m, n) != 0 ||
src.at<uchar>(m, n) < 128) continue;
Expand Down Expand Up @@ -347,7 +347,7 @@ std::vector<YunLabel> Yun::ccl(cv::Mat &src, cv::Mat &oMap, std::vector<YunOrien
{
YunLabel val;

val.roi = cvRect(rect.x, rect.y, width, height);
val.roi = cv::Rect(rect.x, rect.y, width, height);

int max_val = 0;
int ori = 255;
Expand Down Expand Up @@ -400,13 +400,13 @@ std::vector<YunCandidate> Yun::calc_candidate(std::vector<YunLabel> &val, cv::Ma
{
bool isSave = true;

cv::Point st = cvPoint(new_tmp.roi.x, new_tmp.roi.y);
cv::Point et = cvPoint(new_tmp.roi.x + new_tmp.roi.width, new_tmp.roi.y + new_tmp.roi.height);
cv::Point st = cv::Point(new_tmp.roi.x, new_tmp.roi.y);
cv::Point et = cv::Point(new_tmp.roi.x + new_tmp.roi.width, new_tmp.roi.y + new_tmp.roi.height);

for (std::vector<YunCandidate>::iterator rit = result.begin(); rit < result.end(); rit++)
{
cv::Point rst = cvPoint(rit->roi.x, rit->roi.y);
cv::Point ret = cvPoint(rit->roi.x + rit->roi.width, rit->roi.y + rit->roi.height);
cv::Point rst = cv::Point(rit->roi.x, rit->roi.y);
cv::Point ret = cv::Point(rit->roi.x + rit->roi.width, rit->roi.y + rit->roi.height);

// compare!
//if (new_tmp.roi.contains(rst) || new_tmp.roi.contains(ret) ||
Expand Down Expand Up @@ -457,7 +457,7 @@ YunCandidate Yun::sub_candidate(YunLabel val, cv::Mat &mMap, cv::Mat &oMap)
cv::Size imSz = mMap.size();

// center point
cv::Point_<double> cPt = cvPoint(roi.x + (roi.width / 2), roi.y + (roi.height / 2));
cv::Point_<double> cPt = cv::Point(roi.x + (roi.width / 2), roi.y + (roi.height / 2));

// check dir
double theta;
Expand Down Expand Up @@ -545,8 +545,8 @@ YunCandidate Yun::calc_region_check(YunCandidate val, cv::Size imSz)

int margin = 1;

cv::Point st = cvPoint(val.roi.x, val.roi.y);
cv::Point et = cvPoint(val.roi.x + val.roi.width, val.roi.y + val.roi.height);
cv::Point st = cv::Point(val.roi.x, val.roi.y);
cv::Point et = cv::Point(val.roi.x + val.roi.width, val.roi.y + val.roi.height);

// st
if (st.y >= val.last_pt.y) new_val.roi.y = val.last_pt.y - margin;
Expand Down

0 comments on commit 7c2ae70

Please sign in to comment.