• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

georgia-tech-db / eva / #891

24 Sep 2023 05:55PM UTC coverage: 73.57% (+37.0%) from 36.589%
#891

push

circleci

web-flow
feat: print error msg if creating built-in functions failed (#1204)

8991 of 12221 relevant lines covered (73.57%)

0.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/evadb/functions/ndarray/annotate.py
1
# coding=utf-8
2
# Copyright 2018-2023 EvaDB
3
#
4
# Licensed under the Apache License, Version 2.0 (the "License");
5
# you may not use this file except in compliance with the License.
6
# You may obtain a copy of the License at
7
#
8
#     http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15
import numpy as np
×
16
import pandas as pd
×
17

18
from evadb.catalog.catalog_type import NdArrayType
×
19
from evadb.functions.abstract.abstract_function import AbstractFunction
×
20
from evadb.functions.decorators.decorators import forward, setup
×
21
from evadb.functions.decorators.io_descriptors.data_types import PandasDataframe
×
22
from evadb.utils.generic_utils import try_to_import_cv2
×
23

24
color = (207, 248, 64)
×
25
thickness = 4
×
26

27

28
class Annotate(AbstractFunction):
×
29
    @setup(cacheable=False, function_type="cv2-transformation", batchable=True)
×
30
    def setup(self):
×
31
        pass
×
32

33
    @property
×
34
    def name(self):
×
35
        return "Annotate"
×
36

37
    @forward(
×
38
        input_signatures=[
39
            PandasDataframe(
40
                columns=["data", "labels", "bboxes"],
41
                column_types=[
42
                    NdArrayType.FLOAT32,
43
                    NdArrayType.STR,
44
                    NdArrayType.FLOAT32,
45
                ],
46
                column_shapes=[(None, None, 3), (None,), (None,)],
47
            )
48
        ],
49
        output_signatures=[
50
            PandasDataframe(
51
                columns=["annotated_frame_array"],
52
                column_types=[NdArrayType.FLOAT32],
53
                column_shapes=[(None, None, 3)],
54
            )
55
        ],
56
    )
57
    def forward(self, df: pd.DataFrame) -> pd.DataFrame:
×
58
        """
59
        Modify the frame to annotate the bbox on it.
60

61
         Returns:
62
             ret (pd.DataFrame): The modified frame.
63
        """
64

65
        def annotate(row: pd.Series) -> np.ndarray:
×
66
            row = row.to_list()
×
67
            frame = row[0]
×
68
            bboxes = row[2]
×
69
            try_to_import_cv2()
×
70
            import cv2
×
71

72
            for bbox in bboxes:
×
73
                x1, y1, x2, y2 = np.asarray(bbox, dtype="int")
×
74
                x1, y1, x2, y2 = int(x1), int(y1), int(x2), int(y2)
×
75
                frame = cv2.rectangle(frame, (x1, y1), (x2, y2), color, thickness)
×
76
            return frame
×
77

78
        ret = pd.DataFrame()
×
79
        ret["annotated_frame_array"] = df.apply(annotate, axis=1)
×
80
        return ret
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc