Skip to content

Commit 4b1bab5

Browse files
Img_processing: arange defines and includes order
1 parent 68b097a commit 4b1bab5

7 files changed

Lines changed: 27 additions & 32 deletions

File tree

img_processing/data.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
[
22
{
3-
"path": "../tests/images/road.mov",
3+
"path": "C:/Users/user1/Desktop/day/sun/sun_in_street.mov",
44
"focal_length": 1500,
55
"is_travel": true
66
},
77
{
8-
"path": "../tests/images/close_cars.mov",
8+
"path": "C:/Users/user1/Desktop/day/close_cars/road.mov",
99
"focal_length": 2000,
1010
"is_travel": true
11-
},
12-
{
13-
"path": "../tests/images/sun_in_street.mov",
14-
"focal_length": 1000,
15-
"is_travel": true
1611
}
17-
]
12+
]

img_processing/include/sun_detector.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class SunDetector {
77
public:
88
void detectSun(const std::shared_ptr<cv::Mat> &frame);
99
void drowSun(std::shared_ptr<cv::Mat> &frame);
10+
bool isSunDetected() const;
1011

1112
private:
1213
cv::Point2f center;

img_processing/src/manager.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ void Manager::mainDemo()
4949
int focalLength;
5050
bool isTravel;
5151
// Open the JSON file
52-
// Open the JSON file
5352
std::ifstream file("../data.json");
5453

5554
if (!file.is_open()) {

img_processing/src/sun_detector.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,8 @@ void SunDetector::drowSun(std::shared_ptr<cv::Mat> &frame)
7272
circle(*frame, center, static_cast<int>(radius), Scalar(0, 255, 0), 2);
7373
}
7474
}
75+
76+
bool SunDetector::isSunDetected() const
77+
{
78+
return isSun;
79+
}
1.27 MB
Loading
1.1 MB
Loading

img_processing/tests/test_sun_detector.cpp

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,26 @@ using namespace cv;
77

88
TEST(SunDetectorTest, detectSun)
99
{
10-
VideoCapture capture("../tests/images/sun_in_street.mov");
11-
12-
if (!capture.isOpened()) {
13-
// LogManager::logErrorMessage(ErrorType::VIDEO_ERROR, "video not found");
14-
// throw runtime_error("video not found");
15-
cout << "couldn't open video" << endl;
10+
Mat img = imread("sun.png");
11+
SunDetector sd;
12+
if (img.empty()) {
13+
cout << "error open img" << endl;
1614
return;
1715
}
18-
Mat img;
19-
SunDetector sd;
20-
while (1) {
21-
capture >> img;
16+
shared_ptr<Mat> frame = make_shared<Mat>(img);
17+
sd.detectSun(frame);
18+
EXPECT_TRUE(sd.isSunDetected());
19+
}
2220

23-
if (img.empty()) {
24-
// LogManager::logInfoMessage(InfoType::MEDIA_FINISH);
25-
cout << "media finish" << endl;
26-
break;
27-
}
28-
shared_ptr<Mat> frame = make_shared<Mat>(img);
29-
sd.detectSun(frame);
30-
sd.drowSun(frame);
31-
imshow("sun", *frame);
32-
int key = waitKey(1);
33-
if (key == 27) {
34-
break;
35-
}
21+
TEST(SunDetectorTest, noSun)
22+
{
23+
Mat img = imread("no_sun.png");
24+
SunDetector sd;
25+
if (img.empty()) {
26+
cout << "error open img" << endl;
27+
return;
3628
}
29+
shared_ptr<Mat> frame = make_shared<Mat>(img);
30+
sd.detectSun(frame);
31+
EXPECT_FALSE(sd.isSunDetected());
3732
}

0 commit comments

Comments
 (0)