Skip to content

Commit

Permalink
OpenCV is again an optional dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
BrennoCaldato committed Apr 16, 2021
1 parent 77aa418 commit 2c9d2f2
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Expand Up @@ -87,7 +87,6 @@ set(OPENSHOT_SOURCES
Json.cpp
KeyFrame.cpp
TrackedObjectBase.cpp
TrackedObjectBBox.cpp
OpenShotVersion.cpp
ZmqLogger.cpp
PlayerBase.cpp
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Clip.cpp
Expand Up @@ -40,7 +40,6 @@
#include "ChunkReader.h"
#include "DummyReader.h"
#include "Timeline.h"
#include "effects/Tracker.h"

using namespace openshot;

Expand Down Expand Up @@ -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){

Expand All @@ -1178,9 +1178,9 @@ void Clip::AddEffect(EffectBase* effect)
// Add the Tracked Object to the timeline
parentTimeline->AddTrackedObject(trackedObjectBBox);
}

}
}
#endif

// Clear cache
cache.Clear();
Expand Down
2 changes: 1 addition & 1 deletion src/OpenShot.h
Expand Up @@ -132,7 +132,6 @@
#include "TextReader.h"
#endif
#include "KeyFrame.h"
#include "TrackedObjectBBox.h"
#include "PlayerBase.h"
#include "Point.h"
#include "Profiles.h"
Expand All @@ -147,6 +146,7 @@
#include "CVStabilization.h"
#include "CVTracker.h"
#include "CVObjectDetection.h"
#include "TrackedObjectBBox.h"
#endif

#endif
2 changes: 2 additions & 0 deletions src/Timeline.cpp
Expand Up @@ -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 {

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions src/Timeline.h
Expand Up @@ -48,7 +48,9 @@
#include "Fraction.h"
#include "Frame.h"
#include "KeyFrame.h"
#ifdef USE_OPENCV
#include "TrackedObjectBBox.h"
#endif
#include "TrackedObjectBase.h"


Expand Down Expand Up @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion tests/KeyFrame.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -731,3 +734,4 @@ TEST_CASE( "GetBoxValues", "[libopenshot][keyframe]" )
CHECK(boxValues["h"] == 20.0);
CHECK(boxValues["ang"] == 30.0);
}
#endif
7 changes: 5 additions & 2 deletions tests/KeyFrame_Tests.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -519,7 +521,7 @@ TEST(Point_Vector_Constructor)

}; // SUITE


#ifdef USE_OPENCV
TEST(TrackedObjectBBox_init_test) {

TrackedObjectBBox kfb;
Expand Down Expand Up @@ -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

0 comments on commit 2c9d2f2

Please sign in to comment.