Skip to content

Commit f8198d6

Browse files
committed
Fixed codacy review warnings
1 parent cb61f91 commit f8198d6

File tree

6 files changed

+16
-12
lines changed

6 files changed

+16
-12
lines changed

src/CVObjectDetection.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ using google::protobuf::util::TimeUtil;
3838
CVObjectDetection::CVObjectDetection(std::string processInfoJson, ProcessingController &processingController)
3939
: processingController(&processingController), processingDevice("CPU"){
4040
SetJson(processInfoJson);
41+
confThreshold = 0.5;
42+
nmsThreshold = 0.1;
4143
}
4244

4345
void CVObjectDetection::setProcessingDevice(){
@@ -69,17 +71,14 @@ void CVObjectDetection::detectObjectsClip(openshot::Clip &video, size_t _start,
6971
std::string line;
7072
while (std::getline(ifs, line)) classNames.push_back(line);
7173

72-
confThreshold = 0.5;
73-
nmsThreshold = 0.1;
74-
7574
// Load the network
7675
if(classesFile == "" || modelConfiguration == "" || modelWeights == "")
7776
return;
7877
net = cv::dnn::readNetFromDarknet(modelConfiguration, modelWeights);
7978
setProcessingDevice();
8079

8180
size_t frame_number;
82-
if(!process_interval || end == 0 || end-start <= 0){
81+
if(!process_interval || end == 0 || end-start == 0){
8382
// Get total number of frames in video
8483
start = video.Start() * video.Reader()->info.fps.ToInt();
8584
end = video.End() * video.Reader()->info.fps.ToInt();

src/CVStabilization.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ using google::protobuf::util::TimeUtil;
3939
CVStabilization::CVStabilization(std::string processInfoJson, ProcessingController &processingController)
4040
: processingController(&processingController){
4141
SetJson(processInfoJson);
42+
start = 0;
43+
end = 0;
4244
}
4345

4446
// Process clip and store necessary stabilization data
@@ -58,7 +60,7 @@ void CVStabilization::stabilizeClip(openshot::Clip& video, size_t _start, size_t
5860
cv::Size readerDims(video.Reader()->info.width, video.Reader()->info.height);
5961

6062
size_t frame_number;
61-
if(!process_interval || end == 0 || end-start <= 0){
63+
if(!process_interval || end == 0 || end-start == 0){
6264
// Get total number of frames in video
6365
start = video.Start() * video.Reader()->info.fps.ToInt();
6466
end = video.End() * video.Reader()->info.fps.ToInt();
@@ -230,7 +232,7 @@ std::map<size_t,CamTrajectory> CVStabilization::SmoothTrajectory(std::vector <Ca
230232
int count = 0;
231233

232234
for(int j=-smoothingWindow; j <= smoothingWindow; j++) {
233-
if(i+j >= 0 && i+j < trajectory.size()) {
235+
if(i+j < trajectory.size()) {
234236
sum_x += trajectory[i+j].x;
235237
sum_y += trajectory[i+j].y;
236238
sum_a += trajectory[i+j].a;

src/CVTracker.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ using google::protobuf::util::TimeUtil;
4040
CVTracker::CVTracker(std::string processInfoJson, ProcessingController &processingController)
4141
: processingController(&processingController), json_interval(false){
4242
SetJson(processInfoJson);
43+
start = 0;
44+
end = 0;
4345
}
4446

4547
// Set desirable tracker method

src/sort_filter/Hungarian.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,9 @@ void HungarianAlgorithm::buildassignmentvector(
192192
int nOfRows,
193193
int nOfColumns)
194194
{
195-
int row, col;
196195

197-
for (row = 0; row < nOfRows; row++)
198-
for (col = 0; col < nOfColumns; col++)
196+
for (int row = 0; row < nOfRows; row++)
197+
for (int col = 0; col < nOfColumns; col++)
199198
if (starMatrix[row + nOfRows * col])
200199
{
201200
#ifdef ONE_INDEXING

src/sort_filter/sort.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ SortTracker::SortTracker(int max_age, int min_hits)
77
{
88
_min_hits = min_hits;
99
_max_age = max_age;
10+
alive_tracker = true;
1011
}
1112

1213
// Computes IOU between two bounding boxes
@@ -154,11 +155,10 @@ void SortTracker::update(vector<cv::Rect> detections_cv, int frame_count, double
154155
matchedPairs.push_back(cv::Point(i, assignment[i]));
155156
}
156157

157-
int detIdx, trkIdx;
158158
for (unsigned int i = 0; i < matchedPairs.size(); i++)
159159
{
160-
trkIdx = matchedPairs[i].x;
161-
detIdx = matchedPairs[i].y;
160+
int trkIdx = matchedPairs[i].x;
161+
int detIdx = matchedPairs[i].y;
162162
trackers[trkIdx].update(detections[detIdx].box);
163163
trackers[trkIdx].classId = detections[detIdx].classId;
164164
trackers[trkIdx].confidence = detections[detIdx].confidence;

src/sort_filter/sort.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ typedef struct TrackingBox
2222
int classId = 0;
2323
int id = 0;
2424
cv::Rect_<float> box = cv::Rect_<float>(0.0, 0.0, 0.0, 0.0);
25+
TrackingBox() {}
26+
TrackingBox(int _frame, float _confidence, int _classId, int _id) : frame(_frame), confidence(_confidence), classId(_classId), id(_id) {}
2527
} TrackingBox;
2628

2729
class SortTracker

0 commit comments

Comments
 (0)