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_imfindcircles.cpp~ | 148 ++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 sci_gateway/cpp/opencv_imfindcircles.cpp~ (limited to 'sci_gateway/cpp/opencv_imfindcircles.cpp~') diff --git a/sci_gateway/cpp/opencv_imfindcircles.cpp~ b/sci_gateway/cpp/opencv_imfindcircles.cpp~ new file mode 100644 index 0000000..7201e7d --- /dev/null +++ b/sci_gateway/cpp/opencv_imfindcircles.cpp~ @@ -0,0 +1,148 @@ +/******************************************************** +Function :imfindcircles +Syntax :B=imfindcircles(A) +Author: Tess Zacharias + +********************************************************/ + +#include +#include "opencv2/core/core.hpp" +#include "opencv2/highgui/highgui.hpp" +#include "opencv2/opencv.hpp" +#include +using namespace cv; +using namespace std; +extern "C" +{ + #include "api_scilab.h" + #include "Scierror.h" + #include "BOOL.h" + #include + #include "sciprint.h" + #include "../common.h" + + int opencv_imfindcircles(char *fname, unsigned long fname_len) + { + + SciErr sciErr; + int intErr = 0; + int *piAddrNew = NULL; + int *piAddr2 = NULL; + int *piAddr3 = NULL; + Mat src_gray,image; + double Rmin,Rmax; + //checking input argument + CheckInputArgument(pvApiCtx, 1, 1); + CheckOutputArgument(pvApiCtx, 1, 2) ; + sciprint("here1"); + retrieveImage(image, 1); +// sciErr = getVarAddressFromPosition(pvApiCtx,2,&piAddr2); +// if (sciErr.iErr) +// { +// printError(&sciErr, 0); +// return 0; +// } +// intErr = getScalarDouble(pvApiCtx, piAddr2, &Rmin); +// if(intErr) +// { +// return intErr; +// } +// if(Rmin!= round(Rmin) || Rmin<=0) +// { +// sciprint("The value of minium Radius must be an integer\n"); +// return 0; +// } +// if(Rmin<5) +// { +// sciprint("The value of minium Radius too small\n"); +// return 0; +// } +// sciErr = getVarAddressFromPosition(pvApiCtx,3,&piAddr3); +// if (sciErr.iErr) +// { +// printError(&sciErr, 0); +// return 0; +// } +// intErr = getScalarDouble(pvApiCtx, piAddr3, &Rmax); +// if(intErr) +// { +// return intErr; +// } +// if(Rmax!= round(Rmax) || Rmax<=0) +// { +// sciprint("The value of maximum Radius must be an integer\n"); +// return 0; +// } + sciprint("here2"); + cvtColor(image,src_gray,CV_BGR2GRAY); + GaussianBlur( src_gray, src_gray, Size(9, 9), 2, 2 ); + vector circles; + HoughCircles( src_gray, circles, CV_HOUGH_GRADIENT, 1, src_gray.rows/8, 200, 100,0,0); + sciprint("here3"); + int k=circles.size(); + if (k==0) + {sciprint("zero");} + else if (k==1) + {sciprint("one");} + else if (k==2) + {sciprint("two");} + else if (k==3) + {sciprint("three");} + else + {sciprint(">3");} + double *radius=NULL; + radius=( double *)malloc(sizeof(double)*k); + double *c1=NULL; + c1=( double *)malloc(sizeof(double)*k); + double *c2=NULL; + c2=( double *)malloc(sizeof(double)*k); + sciprint("here4"); + for( size_t i= 0; i < circles.size(); i++ ) + { + c1[i]=cvRound(circles[i][0]); + cout<