From 1e9d1fcedf1a361bcdb384f15b5b14bdb526576d Mon Sep 17 00:00:00 2001
From: AlexeyAB <alexeyab84@gmail.com>
Date: Sat, 30 Jun 2018 20:12:25 +0000
Subject: [PATCH] Fixed arch=compute_53,code=[sm_53,compute_53] for Jetson TX1

---
 src/image.c |   43 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/src/image.c b/src/image.c
index 5313964..a2dc3ca 100644
--- a/src/image.c
+++ b/src/image.c
@@ -1068,6 +1068,49 @@
 	return im;
 }
 
+image get_image_from_stream_letterbox(CvCapture *cap, int w, int h, int c, IplImage** in_img, int cpp_video_capture, int dont_close)
+{
+	c = c ? c : 3;
+	IplImage* src;
+	if (cpp_video_capture) {
+		static int once = 1;
+		if (once) {
+			once = 0;
+			do {
+				src = get_webcam_frame(cap);
+				if (!src) return make_empty_image(0, 0, 0);
+			} while (src->width < 1 || src->height < 1 || src->nChannels < 1);
+			printf("Video stream: %d x %d \n", src->width, src->height);
+		}
+		else
+			src = get_webcam_frame(cap);
+	}
+	else src = cvQueryFrame(cap);
+
+	if (cpp_video_capture)
+		if (!wait_for_stream(cap, src, dont_close)) return make_empty_image(0, 0, 0);
+	*in_img = cvCreateImage(cvSize(src->width, src->height), IPL_DEPTH_8U, c);
+	cvResize(src, *in_img, CV_INTER_LINEAR);
+	image tmp = ipl_to_image(src);
+	image im = letterbox_image(tmp, w, h);
+	free_image(tmp);
+	if (cpp_video_capture) cvReleaseImage(&src);
+	if (c>1) rgbgr_image(im);
+	return im;
+}
+
+int get_stream_fps(CvCapture *cap, int cpp_video_capture)
+{
+	int fps = 25;
+	if (cpp_video_capture) {
+		fps = get_stream_fps_cpp(cap);
+	}
+	else {
+		fps = cvGetCaptureProperty(cap, CV_CAP_PROP_FPS);
+	}
+	return fps;
+}
+
 void save_image_jpg(image p, const char *name)
 {
     image copy = copy_image(p);

--
Gitblit v1.10.0