You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Fixed codacy review warnings
This commit is contained in:
@@ -38,6 +38,8 @@ using google::protobuf::util::TimeUtil;
|
||||
CVObjectDetection::CVObjectDetection(std::string processInfoJson, ProcessingController &processingController)
|
||||
: processingController(&processingController), processingDevice("CPU"){
|
||||
SetJson(processInfoJson);
|
||||
confThreshold = 0.5;
|
||||
nmsThreshold = 0.1;
|
||||
}
|
||||
|
||||
void CVObjectDetection::setProcessingDevice(){
|
||||
@@ -69,9 +71,6 @@ void CVObjectDetection::detectObjectsClip(openshot::Clip &video, size_t _start,
|
||||
std::string line;
|
||||
while (std::getline(ifs, line)) classNames.push_back(line);
|
||||
|
||||
confThreshold = 0.5;
|
||||
nmsThreshold = 0.1;
|
||||
|
||||
// Load the network
|
||||
if(classesFile == "" || modelConfiguration == "" || modelWeights == "")
|
||||
return;
|
||||
@@ -79,7 +78,7 @@ void CVObjectDetection::detectObjectsClip(openshot::Clip &video, size_t _start,
|
||||
setProcessingDevice();
|
||||
|
||||
size_t frame_number;
|
||||
if(!process_interval || end == 0 || end-start <= 0){
|
||||
if(!process_interval || end == 0 || end-start == 0){
|
||||
// Get total number of frames in video
|
||||
start = video.Start() * video.Reader()->info.fps.ToInt();
|
||||
end = video.End() * video.Reader()->info.fps.ToInt();
|
||||
|
||||
@@ -39,6 +39,8 @@ using google::protobuf::util::TimeUtil;
|
||||
CVStabilization::CVStabilization(std::string processInfoJson, ProcessingController &processingController)
|
||||
: processingController(&processingController){
|
||||
SetJson(processInfoJson);
|
||||
start = 0;
|
||||
end = 0;
|
||||
}
|
||||
|
||||
// Process clip and store necessary stabilization data
|
||||
@@ -58,7 +60,7 @@ void CVStabilization::stabilizeClip(openshot::Clip& video, size_t _start, size_t
|
||||
cv::Size readerDims(video.Reader()->info.width, video.Reader()->info.height);
|
||||
|
||||
size_t frame_number;
|
||||
if(!process_interval || end == 0 || end-start <= 0){
|
||||
if(!process_interval || end == 0 || end-start == 0){
|
||||
// Get total number of frames in video
|
||||
start = video.Start() * video.Reader()->info.fps.ToInt();
|
||||
end = video.End() * video.Reader()->info.fps.ToInt();
|
||||
@@ -230,7 +232,7 @@ std::map<size_t,CamTrajectory> CVStabilization::SmoothTrajectory(std::vector <Ca
|
||||
int count = 0;
|
||||
|
||||
for(int j=-smoothingWindow; j <= smoothingWindow; j++) {
|
||||
if(i+j >= 0 && i+j < trajectory.size()) {
|
||||
if(i+j < trajectory.size()) {
|
||||
sum_x += trajectory[i+j].x;
|
||||
sum_y += trajectory[i+j].y;
|
||||
sum_a += trajectory[i+j].a;
|
||||
|
||||
@@ -40,6 +40,8 @@ using google::protobuf::util::TimeUtil;
|
||||
CVTracker::CVTracker(std::string processInfoJson, ProcessingController &processingController)
|
||||
: processingController(&processingController), json_interval(false){
|
||||
SetJson(processInfoJson);
|
||||
start = 0;
|
||||
end = 0;
|
||||
}
|
||||
|
||||
// Set desirable tracker method
|
||||
@@ -71,7 +73,7 @@ void CVTracker::trackClip(openshot::Clip& video, size_t _start, size_t _end, boo
|
||||
if(!json_interval){
|
||||
start = _start; end = _end;
|
||||
|
||||
if(!process_interval || end <= 0 || end-start <= 0){
|
||||
if(!process_interval || end <= 0 || end-start == 0){
|
||||
// Get total number of frames in video
|
||||
start = video.Start() * video.Reader()->info.fps.ToInt();
|
||||
end = video.End() * video.Reader()->info.fps.ToInt();
|
||||
|
||||
@@ -192,10 +192,8 @@ void HungarianAlgorithm::buildassignmentvector(
|
||||
int nOfRows,
|
||||
int nOfColumns)
|
||||
{
|
||||
int row, col;
|
||||
|
||||
for (row = 0; row < nOfRows; row++)
|
||||
for (col = 0; col < nOfColumns; col++)
|
||||
for (int row = 0; row < nOfRows; row++)
|
||||
for (int col = 0; col < nOfColumns; col++)
|
||||
if (starMatrix[row + nOfRows * col])
|
||||
{
|
||||
#ifdef ONE_INDEXING
|
||||
|
||||
@@ -7,6 +7,7 @@ SortTracker::SortTracker(int max_age, int min_hits)
|
||||
{
|
||||
_min_hits = min_hits;
|
||||
_max_age = max_age;
|
||||
alive_tracker = true;
|
||||
}
|
||||
|
||||
// Computes IOU between two bounding boxes
|
||||
@@ -154,11 +155,10 @@ void SortTracker::update(vector<cv::Rect> detections_cv, int frame_count, double
|
||||
matchedPairs.push_back(cv::Point(i, assignment[i]));
|
||||
}
|
||||
|
||||
int detIdx, trkIdx;
|
||||
for (unsigned int i = 0; i < matchedPairs.size(); i++)
|
||||
{
|
||||
trkIdx = matchedPairs[i].x;
|
||||
detIdx = matchedPairs[i].y;
|
||||
int trkIdx = matchedPairs[i].x;
|
||||
int detIdx = matchedPairs[i].y;
|
||||
trackers[trkIdx].update(detections[detIdx].box);
|
||||
trackers[trkIdx].classId = detections[detIdx].classId;
|
||||
trackers[trkIdx].confidence = detections[detIdx].confidence;
|
||||
|
||||
@@ -22,6 +22,8 @@ typedef struct TrackingBox
|
||||
int classId = 0;
|
||||
int id = 0;
|
||||
cv::Rect_<float> box = cv::Rect_<float>(0.0, 0.0, 0.0, 0.0);
|
||||
TrackingBox() {}
|
||||
TrackingBox(int _frame, float _confidence, int _classId, int _id) : frame(_frame), confidence(_confidence), classId(_classId), id(_id) {}
|
||||
} TrackingBox;
|
||||
|
||||
class SortTracker
|
||||
|
||||
@@ -75,7 +75,7 @@ SUITE(CVTracker_Tests)
|
||||
float y = fd.y1;
|
||||
float width = fd.x2 - x;
|
||||
float height = fd.y2 - y;
|
||||
std::cout<<"\n\n Error: "<< processingController.GetErrorMessage() <<"\n";
|
||||
|
||||
// Compare if tracked data is equal to pre-tested ones
|
||||
CHECK_EQUAL(259, (int)(x * 640));
|
||||
CHECK_EQUAL(131, (int)(y * 360));
|
||||
@@ -140,7 +140,7 @@ SUITE(CVTracker_Tests)
|
||||
float y_2 = fd_2.y1;
|
||||
float width_2 = fd_2.x2 - x_2;
|
||||
float height_2 = fd_2.y2 - y_2;
|
||||
std::cout<<"\n\n Error: "<< processingController.GetErrorMessage() <<"\n";
|
||||
|
||||
// Compare first tracker data with second tracker data
|
||||
CHECK_EQUAL((int)(x_1 * 640), (int)(x_2 * 640));
|
||||
CHECK_EQUAL((int)(y_1 * 360), (int)(y_2 * 360));
|
||||
|
||||
Reference in New Issue
Block a user