/** * @file * @brief Unit tests for openshot::Frame * @author Jonathan Thomas * @author FeRD (Frank Dana) * * @ref License */ /* LICENSE * * Copyright (c) 2008-2019 OpenShot Studios, LLC * . This file is part of * OpenShot Library (libopenshot), an open-source project dedicated to * delivering high quality video editing and animation solutions to the * world. For more information visit . * * OpenShot Library (libopenshot) is free software: you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * OpenShot Library (libopenshot) is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with OpenShot Library. If not, see . */ #include "UnitTest++.h" // Prevent name clashes with juce::UnitTest #define DONT_SET_USING_JUCE_NAMESPACE 1 #include "../include/OpenShot.h" #include "../include/ProcessingController.h" #include using namespace openshot; SUITE(CVTracker_Tests) { // Just for the tracker constructor, it won't be used ProcessingController processingController; TEST(Track_Video) { // Create a video clip std::stringstream path; path << TEST_MEDIA_PATH << "test.avi"; // Open clip openshot::Clip c1(path.str()); c1.Open(); // Create tracker CVTracker kcfTracker("{\"protobuf_data_path\": \"\", \"tracker_type\": \"KCF\", \"bbox\": {\"x\": 294, \"y\": 102, \"w\": 180, \"h\": 166}}", processingController); // Track clip for frames 0-20 kcfTracker.trackClip(c1, 0, 20, true); // Get tracked data FrameData fd = kcfTracker.GetTrackedData(20); int x = fd.x1; int y = fd.y1; int width = fd.x2-fd.x1; int height = fd.y2-fd.y1; // Compare if tracked data is equal to pre-tested ones CHECK_EQUAL(259, x); CHECK_EQUAL(131, y); CHECK_EQUAL(180, width); CHECK_EQUAL(166, height); } TEST(SaveLoad_Protobuf) { // Create a video clip std::stringstream path; path << TEST_MEDIA_PATH << "test.avi"; // Open clip openshot::Clip c1(path.str()); c1.Open(); // Create first tracker CVTracker kcfTracker_1("{\"protobuf_data_path\": \"kcf_tracker.data\", \"tracker_type\": \"KCF\", \"bbox\": {\"x\": 294, \"y\": 102, \"w\": 180, \"h\": 166}}", processingController); // Track clip for frames 0-20 kcfTracker_1.trackClip(c1, 0, 20, true); // Get tracked data FrameData fd_1 = kcfTracker_1.GetTrackedData(20); int x_1 = fd_1.x1; int y_1 = fd_1.y1; int width_1 = fd_1.x2-fd_1.x1; int height_1 = fd_1.y2-fd_1.y1; // Save tracked data kcfTracker_1.SaveTrackedData(); // Create second tracker CVTracker kcfTracker_2("{\"protobuf_data_path\": \"kcf_tracker.data\", \"tracker_type\": \"\", \"bbox\": {\"x\": -1, \"y\": -1, \"w\": -1, \"h\": -1}}", processingController); // Load tracked data from first tracker protobuf data kcfTracker_2.LoadTrackedData(); // Get tracked data FrameData fd_2 = kcfTracker_2.GetTrackedData(20); int x_2 = fd_2.x1; int y_2 = fd_2.y1; int width_2 = fd_2.x2-fd_2.x1; int height_2 = fd_2.y2-fd_2.y1; // Compare first tracker data with second tracker data CHECK_EQUAL(x_1, x_2); CHECK_EQUAL(y_1, y_2); CHECK_EQUAL(width_1, width_2); CHECK_EQUAL(height_1, height_2); } } // SUITE(Frame_Tests)