From f0abcfa02b2094396f955c743f7f11fcdb2e3d13 Mon Sep 17 00:00:00 2001
From: IlyaOvodov <b@ovdv.ru>
Date: Mon, 04 Jun 2018 15:57:15 +0000
Subject: [PATCH] Merge branch 'master' of https://github.com/AlexeyAB/darknet into Fix_get_color_depth
---
src/http_stream.cpp | 57 +++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 43 insertions(+), 14 deletions(-)
diff --git a/src/http_stream.cpp b/src/http_stream.cpp
index 5ae8f78..1b65173 100644
--- a/src/http_stream.cpp
+++ b/src/http_stream.cpp
@@ -44,6 +44,12 @@
using std::endl;
#include "opencv2/opencv.hpp"
+#include "opencv2/highgui/highgui.hpp"
+#include "opencv2/highgui/highgui_c.h"
+#include "opencv2/imgproc/imgproc_c.h"
+#ifndef CV_VERSION_EPOCH
+#include "opencv2/videoio/videoio.hpp"
+#endif
using namespace cv;
#include "http_stream.h"
@@ -196,6 +202,18 @@
}
// ----------------------------------------
+CvCapture* get_capture_video_stream(char *path) {
+ CvCapture* cap = NULL;
+ try {
+ cap = (CvCapture*)new cv::VideoCapture(path);
+ }
+ catch (...) {
+ std::cout << " Error: video-stream " << path << " can't be opened! \n";
+ }
+ return cap;
+}
+// ----------------------------------------
+
CvCapture* get_capture_webcam(int index) {
CvCapture* cap = NULL;
try {
@@ -215,14 +233,18 @@
try {
cv::VideoCapture &cpp_cap = *(cv::VideoCapture *)cap;
cv::Mat frame;
- if (cpp_cap.isOpened()) {
+ if (cpp_cap.isOpened())
+ {
cpp_cap >> frame;
- src = cvCreateImage(cvSize(frame.cols, frame.rows), 8, frame.channels());
- *src = frame;
+ IplImage tmp = frame;
+ src = cvCloneImage(&tmp);
+ }
+ else {
+ std::cout << " Video-stream stoped! \n";
}
}
catch (...) {
- std::cout << " Web-camera stoped! \n";
+ std::cout << " Video-stream stoped! \n";
}
return src;
}
@@ -261,19 +283,26 @@
// HSV augmentation
// CV_BGR2HSV, CV_RGB2HSV, CV_HSV2BGR, CV_HSV2RGB
- cv::Mat hsv_src;
- cvtColor(sized, hsv_src, CV_BGR2HSV); // also BGR -> RGB
+ if (ipl->nChannels >= 3)
+ {
+ cv::Mat hsv_src;
+ cvtColor(sized, hsv_src, CV_BGR2HSV); // also BGR -> RGB
- std::vector<cv::Mat> hsv;
- cv::split(hsv_src, hsv);
+ std::vector<cv::Mat> hsv;
+ cv::split(hsv_src, hsv);
- hsv[1] *= dsat;
- hsv[2] *= dexp;
- hsv[0] += 179 * dhue;
+ hsv[1] *= dsat;
+ hsv[2] *= dexp;
+ hsv[0] += 179 * dhue;
- cv::merge(hsv, hsv_src);
+ cv::merge(hsv, hsv_src);
- cvtColor(hsv_src, sized, CV_HSV2RGB); // now RGB instead of BGR
+ cvtColor(hsv_src, sized, CV_HSV2RGB); // now RGB instead of BGR
+ }
+ else
+ {
+ sized *= dexp;
+ }
// Mat -> IplImage -> image
IplImage src = sized;
@@ -283,4 +312,4 @@
}
-#endif // OPENCV
\ No newline at end of file
+#endif // OPENCV
--
Gitblit v1.10.0