From a6df67e8bcd5159cde27556f4f6a315f8dc2215f Mon Sep 17 00:00:00 2001 From: shamikam Date: Mon, 16 Jan 2017 02:56:17 +0530 Subject: First Commit --- sci_gateway/cpp/opencv_mean1.cpp | 64 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 sci_gateway/cpp/opencv_mean1.cpp (limited to 'sci_gateway/cpp/opencv_mean1.cpp') diff --git a/sci_gateway/cpp/opencv_mean1.cpp b/sci_gateway/cpp/opencv_mean1.cpp new file mode 100644 index 0000000..4b85513 --- /dev/null +++ b/sci_gateway/cpp/opencv_mean1.cpp @@ -0,0 +1,64 @@ +/* ==================================================================== */ +/* Author :Priyanka Hiranandani NIT Surat */ +/* ==================================================================== */ +/* Syntax : return_mean=mean(sourceimage) */ +/* ==================================================================== */ +#include +#include "opencv2/core/core.hpp" +#include "opencv2/highgui/highgui.hpp" +#include "opencv2/opencv.hpp" +#include +#include +using namespace cv; +using namespace std; +extern "C" +{ +#include "api_scilab.h" +#include "Scierror.h" +#include "BOOL.h" +#include +#include +#include "../common.h" +int mean1(char *fname, unsigned long fname_len) +{ + + // Error management variable + SciErr sciErr; + // Variables declaration // + int t,i,j,k; + Scalar mean11; + //function to check number of input variable + CheckInputArgument(pvApiCtx, 1, 1); + //function to check number of output variable + CheckOutputArgument(pvApiCtx, 1, 1); + // get Address of first input + Mat image; + retrieveImage(image,1); + //block of code for calculating meanimage + mean11=mean(image,noArray()); + double m=0; + int count=0; + for(int i=0;i<4;i++) + { + if(mean11.val[i]!=0) + { + m=m+mean11.val[i]; + count++; + } + + } + m=m/count; + int error; + error=createScalarDouble(pvApiCtx,nbInputArgument(pvApiCtx)+1,m); + if(error!=0) + { + sciprint("error occurred"); + return 0; + } + ////////// Return the output arguments to the Scilab engine ////////// + AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; + ReturnArguments(pvApiCtx); + return 0; +} +/* ==================================================================== */ +} -- cgit