OpenCV is again an optional dependency

This commit is contained in:
Brenno
2021-04-15 22:05:35 -03:00
parent 77aa418353
commit 2c9d2f2a32
7 changed files with 20 additions and 7 deletions

View File

@@ -87,7 +87,6 @@ set(OPENSHOT_SOURCES
Json.cpp
KeyFrame.cpp
TrackedObjectBase.cpp
TrackedObjectBBox.cpp
OpenShotVersion.cpp
ZmqLogger.cpp
PlayerBase.cpp
@@ -107,6 +106,7 @@ set(OPENSHOT_CV_SOURCES
CVStabilization.cpp
ClipProcessingJobs.cpp
CVObjectDetection.cpp
TrackedObjectBBox.cpp
effects/Stabilizer.cpp
effects/Tracker.cpp
effects/ObjectDetection.cpp

View File

@@ -40,7 +40,6 @@
#include "ChunkReader.h"
#include "DummyReader.h"
#include "Timeline.h"
#include "effects/Tracker.h"
using namespace openshot;
@@ -1158,6 +1157,7 @@ void Clip::AddEffect(EffectBase* effect)
if (parentTimeline)
effect->ParentTimeline(parentTimeline);
#ifdef USE_OPENCV
// Add Tracked Object to Timeline
if (effect->info.has_tracked_object){
@@ -1178,9 +1178,9 @@ void Clip::AddEffect(EffectBase* effect)
// Add the Tracked Object to the timeline
parentTimeline->AddTrackedObject(trackedObjectBBox);
}
}
}
#endif
// Clear cache
cache.Clear();

View File

@@ -132,7 +132,6 @@
#include "TextReader.h"
#endif
#include "KeyFrame.h"
#include "TrackedObjectBBox.h"
#include "PlayerBase.h"
#include "Point.h"
#include "Profiles.h"
@@ -147,6 +146,7 @@
#include "CVStabilization.h"
#include "CVTracker.h"
#include "CVObjectDetection.h"
#include "TrackedObjectBBox.h"
#endif
#endif

View File

@@ -293,6 +293,7 @@ std::list<std::string> Timeline::GetTrackedObjectsIds() const{
return trackedObjects_ids;
}
#ifdef USE_OPENCV
// Return the trackedObject's properties as a JSON string
std::string Timeline::GetTrackedObjectValues(std::string id, int64_t frame_number) const {
@@ -349,6 +350,7 @@ std::string Timeline::GetTrackedObjectValues(std::string id, int64_t frame_numbe
return trackedObjectJson.toStyledString();
}
#endif
// Add an openshot::Clip to the timeline
void Timeline::AddClip(Clip* clip)

View File

@@ -48,7 +48,9 @@
#include "Fraction.h"
#include "Frame.h"
#include "KeyFrame.h"
#ifdef USE_OPENCV
#include "TrackedObjectBBox.h"
#endif
#include "TrackedObjectBase.h"
@@ -254,7 +256,9 @@ namespace openshot {
/// Return the ID's of the tracked objects as a list of strings
std::list<std::string> GetTrackedObjectsIds() const;
/// Return the trackedObject's properties as a JSON string
#ifdef USE_OPENCV
std::string GetTrackedObjectValues(std::string id, int64_t frame_number) const;
#endif
/// @brief Add an openshot::Clip to the timeline
/// @param clip Add an openshot::Clip to the timeline. A clip can contain any type of Reader.

View File

@@ -34,13 +34,15 @@
#include <memory>
#include "KeyFrame.h"
#include "TrackedObjectBBox.h"
#include "Exceptions.h"
#include "Coordinate.h"
#include "Fraction.h"
#include "Clip.h"
#include "Timeline.h"
#ifdef USE_OPENCV
#include "effects/Tracker.h"
#include "TrackedObjectBBox.h"
#endif
#include "Point.h"
using namespace openshot;
@@ -514,6 +516,7 @@ TEST_CASE( "Point_Vector_Constructor", "[libopenshot][keyframe]" )
CHECK(k1.GetValue(10) == Approx(30.0f).margin(0.0001));
}
#ifdef USE_OPENCV
TEST_CASE( "TrackedObjectBBox init", "[libopenshot][keyframe]" )
{
TrackedObjectBBox kfb(62,143,0,212);
@@ -731,3 +734,4 @@ TEST_CASE( "GetBoxValues", "[libopenshot][keyframe]" )
CHECK(boxValues["h"] == 20.0);
CHECK(boxValues["ang"] == 30.0);
}
#endif

View File

@@ -35,7 +35,9 @@
// Prevent name clashes with juce::UnitTest
#define DONT_SET_USING_JUCE_NAMESPACE 1
#include "KeyFrame.h"
#ifdef USE_OPENCV
#include "TrackedObjectBBox.h"
#endif
#include "Exceptions.h"
#include "Coordinate.h"
#include "Fraction.h"
@@ -519,7 +521,7 @@ TEST(Point_Vector_Constructor)
}; // SUITE
#ifdef USE_OPENCV
TEST(TrackedObjectBBox_init_test) {
TrackedObjectBBox kfb;
@@ -704,4 +706,5 @@ TEST(GetBoxValues_test){
CHECK_EQUAL(20.0, boxValues["w"]);
CHECK_EQUAL(20.0, boxValues["h"]);
CHECK_EQUAL(30.0, boxValues["ang"]);
}
}
#endif