From 2c9d2f2a32609ee456ff20ea1d8016a8723f4e3c Mon Sep 17 00:00:00 2001 From: Brenno Date: Thu, 15 Apr 2021 22:05:35 -0300 Subject: [PATCH] OpenCV is again an optional dependency --- src/CMakeLists.txt | 2 +- src/Clip.cpp | 4 ++-- src/OpenShot.h | 2 +- src/Timeline.cpp | 2 ++ src/Timeline.h | 4 ++++ tests/KeyFrame.cpp | 6 +++++- tests/KeyFrame_Tests.cpp | 7 +++++-- 7 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ced0bd1a..76022764 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/Clip.cpp b/src/Clip.cpp index 0d4068cf..4c0e9876 100644 --- a/src/Clip.cpp +++ b/src/Clip.cpp @@ -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(); diff --git a/src/OpenShot.h b/src/OpenShot.h index 5903ae43..f6c80c42 100644 --- a/src/OpenShot.h +++ b/src/OpenShot.h @@ -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 diff --git a/src/Timeline.cpp b/src/Timeline.cpp index 29194410..51c90840 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -293,6 +293,7 @@ std::list 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) diff --git a/src/Timeline.h b/src/Timeline.h index 236e1352..630f93c8 100644 --- a/src/Timeline.h +++ b/src/Timeline.h @@ -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 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. diff --git a/tests/KeyFrame.cpp b/tests/KeyFrame.cpp index a75e5a95..3b32a86a 100644 --- a/tests/KeyFrame.cpp +++ b/tests/KeyFrame.cpp @@ -34,13 +34,15 @@ #include #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 \ No newline at end of file diff --git a/tests/KeyFrame_Tests.cpp b/tests/KeyFrame_Tests.cpp index 33d0f7ae..14864cad 100644 --- a/tests/KeyFrame_Tests.cpp +++ b/tests/KeyFrame_Tests.cpp @@ -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"]); -} \ No newline at end of file +} +#endif \ No newline at end of file