summaryrefslogtreecommitdiff
path: root/sci_gateway/cpp/opencv_imfindcircles.cpp~
diff options
context:
space:
mode:
authorshamikam2017-01-16 02:56:17 +0530
committershamikam2017-01-16 02:56:17 +0530
commita6df67e8bcd5159cde27556f4f6a315f8dc2215f (patch)
treee806e966b06a53388fb300d89534354b222c2cad /sci_gateway/cpp/opencv_imfindcircles.cpp~
downloadFOSSEE_Image_Processing_Toolbox-a6df67e8bcd5159cde27556f4f6a315f8dc2215f.tar.gz
FOSSEE_Image_Processing_Toolbox-a6df67e8bcd5159cde27556f4f6a315f8dc2215f.tar.bz2
FOSSEE_Image_Processing_Toolbox-a6df67e8bcd5159cde27556f4f6a315f8dc2215f.zip
First CommitHEADmaster
Diffstat (limited to 'sci_gateway/cpp/opencv_imfindcircles.cpp~')
-rw-r--r--sci_gateway/cpp/opencv_imfindcircles.cpp~148
1 files changed, 148 insertions, 0 deletions
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 <numeric>
+#include "opencv2/core/core.hpp"
+#include "opencv2/highgui/highgui.hpp"
+#include "opencv2/opencv.hpp"
+#include <iostream>
+using namespace cv;
+using namespace std;
+extern "C"
+{
+ #include "api_scilab.h"
+ #include "Scierror.h"
+ #include "BOOL.h"
+ #include <localization.h>
+ #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<Vec3f> 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<<c1[i];
+ sciprint("here5");
+ c2[i]=cvRound(circles[i][1]);
+ cout<<c2[i];
+ sciprint("here6");
+ radius[i]=cvRound(circles[i][2]);
+ cout<<radius[i];
+ sciprint("here7");
+ }
+ sciErr = createList(pvApiCtx, nbInputArgument(pvApiCtx) + 1, 2, &piAddrNew);
+ if(sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+ sciErr = createMatrixOfDoubleInList(pvApiCtx, nbInputArgument(pvApiCtx)+1, piAddrNew, 1, 1, k, c1);
+ free(c1);
+ if(sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+ sciErr = createMatrixOfDoubleInList(pvApiCtx, nbInputArgument(pvApiCtx)+1, piAddrNew, 2, 1, k, c2);
+ free(c2);
+ if(sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ if(Lhs==2)
+ {
+ sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) +2,1,k,radius);
+ free(radius);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+ AssignOutputVariable(pvApiCtx, 2) = nbInputArgument(pvApiCtx) + 2;
+ }
+ ReturnArguments(pvApiCtx);
+ return 0;
+
+ }
+}