File: CVOutline.cpp

package info (click to toggle)
libopenshot 0.5.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 31,228 kB
  • sloc: cpp: 32,692; python: 92; sh: 77; makefile: 21; ruby: 5
file content (61 lines) | stat: -rw-r--r-- 1,361 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
 * @file
 * @brief Unit tests for OpenCV Outline effect
 * @author Jonathan Thomas <jonathan@openshot.org>
 *
 * @ref License
 */

// Copyright (c) 2008-2025 OpenShot Studios, LLC
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#include <sstream>
#include <memory>
#include <cmath>

#include "openshot_catch.h"

#include "Clip.h"
#include "effects/Outline.h"

using namespace openshot;

TEST_CASE( "Outline_Tests", "[libopenshot][opencv][outline]" )
{
    // Create a video clip
    std::stringstream path;
    path << TEST_MEDIA_PATH << "1F0CF.svg";

    // Open clip
    openshot::Clip c(path.str());
    c.Open();
    auto f = c.GetFrame(1);

    // Create effect constructor (default values)
    openshot::Outline e1{};

    // Get frame from effect
    auto f1 = e1.GetFrame(f, 1);
    std::shared_ptr<QImage> i1 = f1->GetImage();

    // Check effect colors
    QColor pix1 = i1->pixelColor(3, 32);
    QColor compare1{0, 0, 0, 0};
    CHECK(pix1 == compare1);

    // Test another effect constructor
    openshot::Outline e2(Keyframe(3.0), Color(0, 0, 255, 128));

    // Get frame from effect
    auto f2 = e2.GetFrame(f, 1);
    std::shared_ptr<QImage> i2 = f2->GetImage();

    // Check effect colors
    QColor pix2 = i2->pixelColor(11, 35);
    QColor compare2{0, 0, 255, 128};
    CHECK(pix2 == compare2);

    // Close clip
    c.Close();
}