-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlc_scrambled_camera_detector.cpp
More file actions
64 lines (48 loc) · 2.36 KB
/
lc_scrambled_camera_detector.cpp
File metadata and controls
64 lines (48 loc) · 2.36 KB
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
62
63
64
#include "lc_scrambled_camera_detector.h"
#include <algorithm_ext.h>
#include <easy/profiler.h>
#include <line.h>
#include <stl_ext.h>
#include <cstring>
using namespace std;
namespace htwk {
LowerCameraScrambledCameraDetector::LowerCameraScrambledCameraDetector(int8_t *lutCb, int8_t *lutCr,
HtwkVisionConfig &config)
: BaseDetector(lutCb, lutCr, config),
imageWidth(config.lcObjectDetectorConfig.scaledImageWidth),
imageHeight(config.lcObjectDetectorConfig.scaledImageHeight) {
const auto &conf = config.lcScrambledCameraDetector;
modelExecutor.loadModelFromFile(config.tflitePath + "/" + conf.model, {1, imageHeight, imageWidth, channels},
conf.threads);
input = modelExecutor.getInputTensor();
if (config.lcObjectDetectorConfig.scaledImageWidth != config.lcScrambledCameraDetector.scaledImageWidth ||
config.lcObjectDetectorConfig.scaledImageHeight != config.lcScrambledCameraDetector.scaledImageHeight) {
printf("%s:%d - scaled image does not have matching sizes width (%d vs %d), height (%d vs %d\n)", __FILE__,
__LINE__, config.lcObjectDetectorConfig.scaledImageWidth,
config.lcScrambledCameraDetector.scaledImageHeight, config.lcObjectDetectorConfig.scaledImageHeight,
config.lcScrambledCameraDetector.scaledImageHeight);
fflush(stdout);
exit(1);
}
}
LowerCameraScrambledCameraDetector::~LowerCameraScrambledCameraDetector() {}
void LowerCameraScrambledCameraDetector::proceed(std::shared_ptr<ImagePreprocessor> imagePreprocessor) {
Timer t("LowerCameraScrambledCameraDetector", 100);
EASY_FUNCTION();
wasExecutedFlag = false;
if (!config.lcScrambledCameraDetector.run)
return;
wasExecutedFlag = true;
EASY_BLOCK("LowerCameraScrambledCameraDetector Prepare");
std::memcpy(input, imagePreprocessor->getScaledImage().data(),
imagePreprocessor->getScaledImage().size() * sizeof(float));
EASY_END_BLOCK;
EASY_BLOCK("LowerCameraScrambledCameraDetector Execute");
modelExecutor.execute();
EASY_END_BLOCK;
isCameraScrambledFlag = *modelExecutor.getOutputTensor() > 0.99;
}
void LowerCameraScrambledCameraDetector::shouldRun(bool state) {
config.lcScrambledCameraDetector.run = state;
}
} // namespace htwk