File: test_gapi_ot.py

package info (click to toggle)
opencv 4.10.0%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 282,092 kB
  • sloc: cpp: 1,178,079; xml: 682,621; python: 49,092; lisp: 31,150; java: 25,469; ansic: 11,039; javascript: 6,085; sh: 1,214; cs: 601; perl: 494; objc: 210; makefile: 173
file content (58 lines) | stat: -rw-r--r-- 1,606 bytes parent folder | download
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
#!/usr/bin/env python

import numpy as np
import cv2 as cv
import os
import sys
import unittest

from tests_common import NewOpenCVTests


try:

    if sys.version_info[:2] < (3, 0):
        raise unittest.SkipTest('Python 2.x is not supported')

    class gapi_ot_test(NewOpenCVTests):

        def test_ot_smoke(self):
            # Input
            img_path = self.find_file('cv/face/david2.jpg', [os.environ.get('OPENCV_TEST_DATA_PATH')])
            in_image = cv.cvtColor(cv.imread(img_path), cv.COLOR_RGB2BGR)
            in_rects = [ (138, 89, 71, 64) ]
            in_rects_cls = [ 0 ]

            # G-API
            g_in = cv.GMat()
            g_in_rects = cv.GArray.Rect()
            g_in_rects_cls = cv.GArray.Int()
            delta = 0.5

            g_out_rects, g_out_rects_cls, g_track_ids, g_track_sts = \
                cv.gapi.ot.track(g_in, g_in_rects, g_in_rects_cls, delta)


            comp = cv.GComputation(cv.GIn(g_in, g_in_rects, g_in_rects_cls),
                                   cv.GOut(g_out_rects, g_out_rects_cls,
                                           g_track_ids, g_track_sts))

            __, __, __, sts = comp.apply(cv.gin(in_image, in_rects, in_rects_cls),
                args=cv.gapi.compile_args(cv.gapi.ot.cpu.kernels()))

            self.assertEqual(cv.gapi.ot.NEW, sts[0])

except unittest.SkipTest as e:

    message = str(e)

    class TestSkip(unittest.TestCase):
        def setUp(self):
            self.skipTest('Skip tests: ' + message)

        def test_skip():
            pass


if __name__ == '__main__':
    NewOpenCVTests.bootstrap()