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

paulmthompson / WhiskerToolbox / 14366745472

09 Apr 2025 08:51PM UTC coverage: 13.06% (+0.1%) from 12.935%
14366745472

push

github

paulmthompson
clang format and tidy for points header

0 of 2 new or added lines in 1 file covered. (0.0%)

26 existing lines in 4 files now uncovered.

210 of 1608 relevant lines covered (13.06%)

1.25 hits per line

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

44.29
/src/WhiskerToolbox/DataManager/Media/Media_Data.cpp
1

2
#include "Media/Media_Data.hpp"
3

4
#include "utils/opencv_utility.hpp"
5

6
#include <opencv2/core/mat.hpp>
7

8
MediaData::MediaData() {
3✔
9
    int const new_size = _height * _width * _display_format_bytes;
3✔
10
    _rawData.resize(static_cast<size_t>(new_size));
3✔
11
    _processedData.resize(static_cast<size_t>(new_size));
3✔
12
    setFormat(DisplayFormat::Gray);
3✔
13
};
3✔
14

15
void MediaData::setFormat(DisplayFormat const format) {
3✔
16
    _format = format;
3✔
17
    switch (_format) {
3✔
18
        case DisplayFormat::Gray:
3✔
19
            _display_format_bytes = 1;
3✔
20
            break;
3✔
UNCOV
21
        case DisplayFormat::Color:
×
22
            _display_format_bytes = 4;
×
23
            break;
×
24
        default:
×
25
            _display_format_bytes = 1;
×
26
            break;
×
27
    }
28
    int const new_size = _height * _width * _display_format_bytes;
3✔
29
    _rawData.resize(static_cast<size_t>(new_size));
3✔
30
    _processedData.resize(static_cast<size_t>(new_size));
3✔
31
};
3✔
32

33
void MediaData::updateHeight(int const height) {
1✔
34
    _height = height;
1✔
35
    int const new_size = _height * _width * _display_format_bytes;
1✔
36
    _rawData.resize(static_cast<size_t>(new_size));
1✔
37
    _processedData.resize(static_cast<size_t>(new_size));
1✔
38
};
1✔
39

40
void MediaData::updateWidth(int const width) {
1✔
41
    _width = width;
1✔
42
    int const new_size = _height * _width * _display_format_bytes;
1✔
43
    _rawData.resize(static_cast<size_t>(new_size));
1✔
44
    _processedData.resize(static_cast<size_t>(new_size));
1✔
45
};
1✔
46

47
void MediaData::LoadMedia(std::string const & name) {
1✔
48
    doLoadMedia(name);
1✔
49
}
1✔
50

UNCOV
51
void MediaData::LoadFrame(int const frame_id) {
×
52
    doLoadFrame(frame_id);
×
53

UNCOV
54
    _last_loaded_frame = frame_id;
×
55
}
×
56

57
std::vector<uint8_t> const & MediaData::getRawData(int const frame_number) {
×
UNCOV
58
    if (frame_number != _last_loaded_frame) {
×
UNCOV
59
        LoadFrame(frame_number);
×
60
    }
61

UNCOV
62
    return _rawData;
×
63
}
64

65
std::vector<uint8_t> MediaData::getProcessedData(int const frame_number) {
×
UNCOV
66
    if (frame_number != _last_loaded_frame) {
×
UNCOV
67
        LoadFrame(frame_number);
×
68
    }
69

UNCOV
70
    if (_last_processed_frame != _last_loaded_frame) {
×
UNCOV
71
        _processData();
×
72
    }
73

UNCOV
74
    return _processedData;
×
75
}
76

77
void MediaData::setProcess(std::string const & key, std::function<void(cv::Mat & input)> process) {
×
UNCOV
78
    this->_process_chain[key] = std::move(process);
×
79
    _processData();
×
80

81
    notifyObservers();
×
82
    //NOTIFY
83
}
×
84

85
void MediaData::removeProcess(std::string const & key) {
×
UNCOV
86
    _process_chain.erase(key);
×
87
    _processData();
×
88

89
    notifyObservers();
×
90
    //NOTIFY
91
}
×
92

UNCOV
93
void MediaData::_processData() {
×
94
    _processedData = _rawData;
×
95

96
    auto m2 = convert_vector_to_mat(_processedData, getWidth(), getHeight());
×
97

UNCOV
98
    for (auto const & [key, process]: _process_chain) {
×
UNCOV
99
        process(m2);
×
100
    }
101

102
    m2.reshape(1, getWidth() * getHeight());
×
103

104
    _processedData.assign(m2.data, m2.data + m2.total() * m2.channels());
×
105

UNCOV
106
    _last_processed_frame = _last_loaded_frame;
×
UNCOV
107
}
×
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