You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Merge branch 'opencv-code-review' into opencv
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,4 +9,3 @@
|
||||
tags
|
||||
*~
|
||||
|
||||
.vscode/
|
||||
|
||||
@@ -400,8 +400,8 @@ endif()
|
||||
find_package( OpenCV 4 )
|
||||
if (OpenCV_FOUND)
|
||||
message("\nCOMPILING WITH OPENCV\n")
|
||||
set(CMAKE_SWIG_FLAGS "-DUSE_OPENCV=1")
|
||||
add_definitions( -DUSE_OPENCV=1 )
|
||||
list(APPEND CMAKE_SWIG_FLAGS -DUSE_OPENCV=1)
|
||||
target_compile_definitions(openshot PUBLIC USE_OPENCV=1)
|
||||
else()
|
||||
message("\nOPENCV NOT FOUND, SOME FUNCTIONALITIES WILL BE DISABLED\n")
|
||||
endif()
|
||||
|
||||
@@ -95,32 +95,34 @@ set(OPENSHOT_TEST_FILES
|
||||
Timeline_Tests.cpp)
|
||||
|
||||
########## SET OPENCV RELATED TEST FILES ###############
|
||||
set(OPENSHOT_CV_TEST_FILES
|
||||
CVTracker_Tests.cpp
|
||||
CVStabilizer_Tests.cpp
|
||||
# CVObjectDetection_Tests.cpp
|
||||
if(OpenCV_FOUND)
|
||||
set(OPENSHOT_CV_TEST_FILES
|
||||
CVTracker_Tests.cpp
|
||||
CVStabilizer_Tests.cpp
|
||||
# CVObjectDetection_Tests.cpp
|
||||
)
|
||||
set(OPENSHOT_CV_LIBRARIES
|
||||
${OpenCV_LIBS}
|
||||
${PROTOBUF_LIBRARY}
|
||||
)
|
||||
endif()
|
||||
|
||||
################ TESTER EXECUTABLE #################
|
||||
# Create unit test executable (openshot-test)
|
||||
message (STATUS "Tests enabled, test executable will be built as tests/openshot-test")
|
||||
if (OpenCV_FOUND)
|
||||
add_executable(openshot-test
|
||||
tests.cpp
|
||||
${OPENSHOT_TEST_FILES}
|
||||
${OPENSHOT_CV_TEST_FILES})
|
||||
|
||||
# Link libraries to the new executable
|
||||
target_link_libraries(openshot-test openshot ${UnitTest++_LIBRARIES} ${OpenCV_LIBS} ${PROTOBUF_LIBRARY})
|
||||
|
||||
else()
|
||||
add_executable(openshot-test
|
||||
tests.cpp
|
||||
${OPENSHOT_TEST_FILES} )
|
||||
add_executable(openshot-test
|
||||
tests.cpp
|
||||
${OPENSHOT_TEST_FILES}
|
||||
${OPENSHOT_CV_TEST_FILES}
|
||||
)
|
||||
|
||||
# Link libraries to the new executable
|
||||
target_link_libraries(openshot-test openshot ${UnitTest++_LIBRARIES})
|
||||
endif()
|
||||
# Link libraries to the new executable
|
||||
target_link_libraries(openshot-test
|
||||
openshot
|
||||
${UnitTest++_LIBRARIES}
|
||||
${OPENSHOT_CV_LIBRARIES}
|
||||
)
|
||||
|
||||
##### RUNNING TESTS (make os_test / make test) #####
|
||||
# Hook up the 'make os_test' target to the 'openshot-test' executable
|
||||
|
||||
@@ -54,8 +54,18 @@ SUITE(CVTracker_Tests)
|
||||
openshot::Clip c1(path.str());
|
||||
c1.Open();
|
||||
|
||||
std::string proto_data = R"proto(
|
||||
{
|
||||
"protobuf_data_path": "",
|
||||
"tracker-type": "KCF",
|
||||
"region": {"x": 294, "y": 102, "width": 180, "height": 166, "first-frame": 0}
|
||||
} )proto";
|
||||
|
||||
// Create tracker
|
||||
CVTracker kcfTracker("{\"protobuf_data_path\": \"\", \"tracker-type\": \"KCF\", \"region\": {\"x\": 294, \"y\": 102, \"width\": 180, \"height\": 166, \"first-frame\": 0}}", processingController);
|
||||
//CVTracker kcfTracker("{\"protobuf_data_path\": \"\", \"tracker_type\": \"KCF\", \"bbox\": {\"x\": 294, \"y\": 102, \"w\": 180, \"h\": 166}, \"first_frame\": 0}", processingController);
|
||||
CVTracker kcfTracker(proto_data, processingController);
|
||||
|
||||
|
||||
// Track clip for frames 0-20
|
||||
kcfTracker.trackClip(c1, 0, 20, true);
|
||||
// Get tracked data
|
||||
@@ -84,8 +94,18 @@ SUITE(CVTracker_Tests)
|
||||
openshot::Clip c1(path.str());
|
||||
c1.Open();
|
||||
|
||||
std::string proto_data = R"proto(
|
||||
{
|
||||
"protobuf_data_path": "kcf_tracker.data",
|
||||
"tracker_type": "KCF",
|
||||
"bbox": {"x": 294, "y": 102, "w": 180, "h": 166},
|
||||
"first_frame": 0
|
||||
} )proto";
|
||||
|
||||
// Create first tracker
|
||||
CVTracker kcfTracker_1("{\"protobuf_data_path\": \"kcf_tracker.data\", \"tracker-type\": \"KCF\", \"region\": {\"x\": 294, \"y\": 102, \"width\": 180, \"height\": 166, \"first-frame\": 0}}", processingController);
|
||||
//CVTracker kcfTracker_1("{\"protobuf_data_path\": \"kcf_tracker.data\", \"tracker_type\": \"KCF\", \"bbox\": {\"x\": 294, \"y\": 102, \"w\": 180, \"h\": 166}, \"first_frame\": 0}", processingController);
|
||||
CVTracker kcfTracker_1(proto_data, processingController);
|
||||
|
||||
|
||||
// Track clip for frames 0-20
|
||||
kcfTracker_1.trackClip(c1, 0, 20, true);
|
||||
@@ -101,8 +121,18 @@ SUITE(CVTracker_Tests)
|
||||
// Save tracked data
|
||||
kcfTracker_1.SaveTrackedData();
|
||||
|
||||
std::string proto_data_1 = R"proto(
|
||||
{
|
||||
"protobuf_data_path": "kcf_tracker.data",
|
||||
"tracker_type": "",
|
||||
"bbox": {"x": -1, "y": -1, "w": -1, "h": -1},
|
||||
"first_frame": 0
|
||||
} )proto";
|
||||
|
||||
// Create second tracker
|
||||
CVTracker kcfTracker_2("{\"protobuf_data_path\": \"kcf_tracker.data\", \"tracker-type\": \"\", \"region\": {\"x\": -1, \"y\": -1, \"width\": -1, \"height\": -1, \"first-frame\": 0}}", processingController);
|
||||
//CVTracker kcfTracker_2("{\"protobuf_data_path\": \"kcf_tracker.data\", \"tracker_type\": \"\", \"bbox\": {\"x\": -1, \"y\": -1, \"w\": -1, \"h\": -1}, \"first_frame\": 0}", processingController);
|
||||
CVTracker kcfTracker_2(proto_data_1, processingController);
|
||||
|
||||
|
||||
// Load tracked data from first tracker protobuf data
|
||||
kcfTracker_2._LoadTrackedData();
|
||||
|
||||
@@ -157,7 +157,7 @@ TEST(Convert_Image)
|
||||
c1.Open();
|
||||
|
||||
// Get first frame
|
||||
std::shared_ptr<Frame> f1 = c1.GetFrame(1);
|
||||
auto f1 = c1.GetFrame(1);
|
||||
|
||||
// Get first Mat image
|
||||
cv::Mat cvimage = f1->GetImageCV();
|
||||
|
||||
Reference in New Issue
Block a user