Skip to content

Commit b771790

Browse files
author
zhangdanfeng
committed
use rgb
Signed-off-by: zhangdanfeng <[email protected]>
1 parent 82e1989 commit b771790

File tree

7 files changed

+10
-8
lines changed

7 files changed

+10
-8
lines changed

Makefile-rv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ LIBS += $(TFLITE_RUY_LIB_DIR)/libruy_ctx.a \
6262
$(TFLITE_RUY_LIB_DIR)/libruy_prepare_packed_matrices.a \
6363
$(TFLITE_RUY_LIB_DIR)/libruy_denormal.a
6464

65-
# LIBS += /home/craft/workspace/DNN/XNNPACK/build/linux/JDSK/libXNNPACK.a
66-
LIBS += $(TFLITE_XNNPACK_DIR)/libXNNPACK.a
65+
LIBS += /home/craft/workspace/DNN/XNNPACK/build/linux/JDSK/libXNNPACK.a
66+
# LIBS += $(TFLITE_XNNPACK_DIR)/libXNNPACK.a
6767
LIBS += $(TFLITE_PTHREADPOOL_DIR)/libpthreadpool.a
6868
LIBS += $(TFLITE_FLATBUF_LIB_DIR)/libflatbuffers.a
6969
LIBS += $(TFLITE_FARMHASH_LIB_DIR)/libfarmhash.a

detection.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ int main(int argc, char **argv) {
160160

161161
auto start = std::chrono::high_resolution_clock::now();
162162
// Predict on the input image
163+
cv::Mat show_image;
164+
input_image.copyTo(show_image);
163165
model.run(input_image, out_pred);
164166
auto stop = std::chrono::high_resolution_clock::now();
165167
auto duration =
@@ -176,13 +178,13 @@ int main(int argc, char **argv) {
176178
auto box = boxes[i];
177179
auto score = scores[i];
178180
auto label = labels[i];
179-
cv::rectangle(input_image, box, cv::Scalar(255, 0, 0), 2);
180-
cv::putText(input_image, labelNames[label], cv::Point(box.x, box.y),
181+
cv::rectangle(show_image, box, cv::Scalar(255, 0, 0), 2);
182+
cv::putText(show_image, labelNames[label], cv::Point(box.x, box.y),
181183
cv::FONT_HERSHEY_COMPLEX, 1.0, cv::Scalar(255, 255, 255), 1,
182184
cv::LINE_AA);
183185
}
184186

185-
cv::imwrite("out.png", input_image);
187+
cv::imwrite("out.png", show_image);
186188

187189
std::cout << "detection completes! " << std::endl;
188190

detection/image.jpg

-136 Bytes
Loading

detection/out.png

-515 Bytes
Loading
Binary file not shown.

yolov5.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void YOLOV5::loadModel(const std::string path) {
6363
}
6464

6565
void YOLOV5::preprocess(cv::Mat &image) {
66-
// cv::cvtColor(image, image, cv::COLOR_BGR2RGB);
66+
cv::cvtColor(image, image, cv::COLOR_BGR2RGB);
6767
// cv::resize(image, image, cv::Size(_in_height, _in_width), cv::INTER_CUBIC);
6868
cv::resize(image, image, cv::Size(_in_height, _in_width));
6969
cv::imwrite("image.jpg", image);
@@ -149,7 +149,7 @@ void YOLOV5::nonMaximumSupprition(std::vector<std::vector<float>> &predV,
149149
indices);
150150
}
151151

152-
void YOLOV5::run(cv::Mat frame, Prediction &out_pred) {
152+
void YOLOV5::run(cv::Mat &frame, Prediction &out_pred) {
153153
_img_height = frame.rows;
154154
_img_width = frame.cols;
155155

yolov5.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class YOLOV5 {
4343
// Take a model path as string
4444
void loadModel(const std::string path);
4545
// Take an image and return a prediction
46-
void run(cv::Mat image, Prediction &out_pred);
46+
void run(cv::Mat &image, Prediction &out_pred);
4747

4848
void getLabelsName(std::string path, std::vector<std::string> &labelNames);
4949

0 commit comments

Comments
 (0)