Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
- Moved TimeUtil from header to src
- Fixed issue with Qimage -> Mat conversion
  • Loading branch information
BrennoCaldato committed Jan 13, 2021
1 parent 7fbb8a2 commit f6de533
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 30 deletions.
2 changes: 2 additions & 0 deletions src/CVObjectDetection.cpp
Expand Up @@ -29,9 +29,11 @@
*/

#include "CVObjectDetection.h"
#include <google/protobuf/util/time_util.h>

using namespace std;
using namespace openshot;
using google::protobuf::util::TimeUtil;

CVObjectDetection::CVObjectDetection(std::string processInfoJson, ProcessingController &processingController)
: processingController(&processingController), processingDevice("CPU"){
Expand Down
4 changes: 0 additions & 4 deletions src/CVObjectDetection.h
Expand Up @@ -30,8 +30,6 @@

#pragma once

#include <google/protobuf/util/time_util.h>

#define int64 opencv_broken_int
#define uint64 opencv_broken_uint
#include <opencv2/dnn.hpp>
Expand All @@ -48,8 +46,6 @@

namespace openshot
{
using google::protobuf::util::TimeUtil;

// Stores the detected object bounding boxes and its properties.
struct CVDetectionData{
CVDetectionData(){}
Expand Down
3 changes: 2 additions & 1 deletion src/CVStabilization.cpp
Expand Up @@ -29,10 +29,11 @@
*/

#include "CVStabilization.h"
#include <google/protobuf/util/time_util.h>

using namespace std;
using namespace openshot;

using google::protobuf::util::TimeUtil;

// Set default smoothing window value to compute stabilization
CVStabilization::CVStabilization(std::string processInfoJson, ProcessingController &processingController)
Expand Down
4 changes: 0 additions & 4 deletions src/CVStabilization.h
Expand Up @@ -31,8 +31,6 @@
#ifndef OPENSHOT_STABILIZATION_H
#define OPENSHOT_STABILIZATION_H

#include <google/protobuf/util/time_util.h>

#define int64 opencv_broken_int
#define uint64 opencv_broken_uint
#include <opencv2/opencv.hpp>
Expand All @@ -45,8 +43,6 @@
#include "Clip.h"
#include "Json.h"

using google::protobuf::util::TimeUtil;

// Store the relative transformation parameters between consecutive frames
struct TransformParam
{
Expand Down
2 changes: 2 additions & 0 deletions src/CVTracker.cpp
Expand Up @@ -29,9 +29,11 @@
*/

#include "CVTracker.h"
#include <google/protobuf/util/time_util.h>

using namespace std;
using namespace openshot;
using google::protobuf::util::TimeUtil;


// Constructor
Expand Down
4 changes: 0 additions & 4 deletions src/CVTracker.h
Expand Up @@ -31,8 +31,6 @@
#ifndef OPENSHOT_CVTRACKER_H
#define OPENSHOT_CVTRACKER_H

#include <google/protobuf/util/time_util.h>

#define int64 opencv_broken_int
#define uint64 opencv_broken_uint
#include <opencv2/opencv.hpp>
Expand All @@ -51,8 +49,6 @@

#include "sort_filter/sort.hpp"

using google::protobuf::util::TimeUtil;

namespace openshot
{

Expand Down
2 changes: 1 addition & 1 deletion src/Frame.cpp
Expand Up @@ -943,7 +943,7 @@ std::shared_ptr<QImage> Frame::GetImage()
// Convert Qimage to Mat
cv::Mat Frame::Qimage2mat( std::shared_ptr<QImage>& qimage) {

cv::Mat mat = cv::Mat(qimage->height(), qimage->width(), CV_8UC4, (const uchar*)qimage->constbits(), qimage->bytesPerLine()).clone();
cv::Mat mat = cv::Mat(qimage->height(), qimage->width(), CV_8UC4, (uchar*)qimage->constBits(), qimage->bytesPerLine()).clone();
cv::Mat mat2 = cv::Mat(mat.rows, mat.cols, CV_8UC3 );
int from_to[] = { 0,0, 1,1, 2,2 };
cv::mixChannels( &mat, 1, &mat2, 1, from_to, 3 );
Expand Down
8 changes: 1 addition & 7 deletions src/effects/ObjectDetection.cpp
Expand Up @@ -72,7 +72,7 @@ std::shared_ptr<Frame> ObjectDetection::GetFrame(std::shared_ptr<Frame> frame, i
{
// Get the frame's image
cv::Mat cv_image = frame->GetImageCV();
std::cout<<"Frame number: "<<frame_number<<"\n\n";

// Check if frame isn't NULL
if(cv_image.empty()){
return frame;
Expand Down Expand Up @@ -125,8 +125,6 @@ void ObjectDetection::drawPred(int classId, float conf, cv::Rect2d box, cv::Mat&

cv::rectangle(frame, cv::Point(left, top - round(1.025*labelSize.height)), cv::Point(left + round(1.025*labelSize.width), top + baseLine), classesColor[classId], cv::FILLED);
putText(frame, label, cv::Point(left+1, top), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0,0,0),1);
std::cout<<"X1: "<<box.x<<" Y1: "<<box.y<<" X2: "<<box.width + box.x<<" Y2: "<<box.height + box.y<<"\n";
std::cout<<"Class: "<<label<<"\n\n";
}

// Load protobuf data file
Expand Down Expand Up @@ -195,10 +193,6 @@ bool ObjectDetection::LoadObjDetectdData(std::string inputFilePath){
detectionsData[id] = DetectionData(classIds, confidences, boxes, id);
}

// Show the time stamp from the last update in object detector data file
if (objMessage.has_last_updated())
cout << " Loaded Data. Saved Time Stamp: " << TimeUtil::ToString(objMessage.last_updated()) << endl;

// Delete all global objects allocated by libprotobuf.
google::protobuf::ShutdownProtobufLibrary();

Expand Down
2 changes: 2 additions & 0 deletions src/effects/Stabilizer.cpp
Expand Up @@ -29,9 +29,11 @@
*/

#include "effects/Stabilizer.h"
#include <google/protobuf/util/time_util.h>

using namespace std;
using namespace openshot;
using google::protobuf::util::TimeUtil;

/// Blank constructor, useful when using Json to load the effect properties
Stabilizer::Stabilizer(std::string clipStabilizedDataPath):protobuf_data_path(clipStabilizedDataPath)
Expand Down
4 changes: 0 additions & 4 deletions src/effects/Stabilizer.h
Expand Up @@ -33,8 +33,6 @@

#include "../EffectBase.h"

#include <google/protobuf/util/time_util.h>

#include <cmath>
#include <stdio.h>
#include <memory>
Expand All @@ -43,8 +41,6 @@
#include "../KeyFrame.h"
#include "protobuf_messages/stabilizedata.pb.h"

using google::protobuf::util::TimeUtil;

// Store the relative transformation parameters between consecutive frames
struct EffectTransformParam
{
Expand Down
2 changes: 2 additions & 0 deletions src/effects/Tracker.cpp
Expand Up @@ -29,9 +29,11 @@
*/

#include "effects/Tracker.h"
#include <google/protobuf/util/time_util.h>

using namespace std;
using namespace openshot;
using google::protobuf::util::TimeUtil;

/// Blank constructor, useful when using Json to load the effect properties
Tracker::Tracker(std::string clipTrackerDataPath)
Expand Down
5 changes: 0 additions & 5 deletions src/effects/Tracker.h
Expand Up @@ -33,8 +33,6 @@

#include "../EffectBase.h"

#include <google/protobuf/util/time_util.h>

#include <cmath>
#include <fstream>
#include <stdio.h>
Expand All @@ -44,9 +42,6 @@
#include "../KeyFrame.h"
#include "protobuf_messages/trackerdata.pb.h"

using google::protobuf::util::TimeUtil;


// Tracking info struct
struct EffectFrameData{
size_t frame_id = -1;
Expand Down

0 comments on commit f6de533

Please sign in to comment.