1From 575409a14e62f73e83309daf8ff6642a235f250c Mon Sep 17 00:00:00 2001
2From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
3Date: Fri, 16 Oct 2020 23:06:36 +0200
4Subject: [PATCH] src/mod/applications/mod_cv/mod_cv.cpp: fix build with opencv
5 3.4.9
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10Use cvScalar instead of CV_RGB to avoid the following build failure with
11opencv 3.4.9:
12
13mod_cv.cpp:693:24: error: conversion from ‘cv::Scalar {aka cv::Scalar_<double>}’ to non-scalar type ‘CvScalar’ requested
14         CvScalar col = CV_RGB((float)255 * object_neighbors / max_neighbors, 0, 0);
15                        ^
16
17Indeed, CV_RGB is defined as cv::Scalar instead of cvScalar since
18version 3.4.2 and
19https://github.com/opencv/opencv/commit/7f9253ea0a9fe2635926379420002dbf0c3fce0f
20
21It should be noted that CV_RGB(r,g,b) = cvScalar(b,g,r,0)
22
23Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
24[Upstream status: https://github.com/signalwire/freeswitch/pull/914]
25---
26 src/mod/applications/mod_cv/mod_cv.cpp | 2 +-
27 1 file changed, 1 insertion(+), 1 deletion(-)
28
29diff --git a/src/mod/applications/mod_cv/mod_cv.cpp b/src/mod/applications/mod_cv/mod_cv.cpp
30index 582f925abf..bbec755e91 100644
31--- a/src/mod/applications/mod_cv/mod_cv.cpp
32+++ b/src/mod/applications/mod_cv/mod_cv.cpp
33@@ -690,7 +690,7 @@ void detectAndDraw(cv_context_t *context)
34 		//printf("WTF %d\n", object_neighbors);
35         //cout << "Detected " << object_neighbors << " object neighbors" << endl;
36         const int rect_height = cvRound((float)img.rows * object_neighbors / max_neighbors);
37-        CvScalar col = CV_RGB((float)255 * object_neighbors / max_neighbors, 0, 0);
38+        CvScalar col = cvScalar(0, 0, (float)255 * object_neighbors / max_neighbors, 0);
39         rectangle(img, cvPoint(0, img.rows), cvPoint(img.cols/10, img.rows - rect_height), col, -1);
40
41         parse_stats(&context->nestDetected, nestedObjects.size(), context->skip);
42--
432.28.0
44
45