Skip to content

Commit

Permalink
Applied code review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
BrennoCaldato committed Nov 5, 2020
1 parent 2bd6bd4 commit 111883e
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 26 deletions.
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -9,4 +9,3 @@
tags
*~

.vscode/
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Expand Up @@ -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()
Expand Down
40 changes: 21 additions & 19 deletions tests/CMakeLists.txt
Expand Up @@ -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
Expand Down
36 changes: 33 additions & 3 deletions tests/CVTracker_Tests.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion tests/Frame_Tests.cpp
Expand Up @@ -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();
Expand Down

0 comments on commit 111883e

Please sign in to comment.