summaryrefslogtreecommitdiff
path: root/sci_gateway1/cpp/opencv_SURFPoints.cpp
blob: 93bd6c24c562c8847551e3099f7d558310681a7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/***************************************************
Author : Shashank Shekhar
***************************************************/

#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_SURFPoints(char *fname, unsigned long fname_len)
	{
		SciErr sciErr;
		int *piAddr = NULL;
		int *piChild = NULL;
		int iType = 0;
		int iRows, iCols = 0;
		double *matData = NULL;
	
		double *OrientationData = NULL;
	    double *MetricData = NULL;
		int *LaplacianData = NULL;	    	
		double *ScaleData = NULL;
	
	    CheckInputArgument(pvApiCtx, 1,1);	
        CheckOutputArgument(pvApiCtx,1,6);

       	sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
		if(sciErr.iErr)
		{
			printError(&sciErr, 0);
			return 0;
		}      	
		
		sciErr = getVarType(pvApiCtx, piAddr, &iType);
		if(sciErr.iErr || iType != sci_matrix || isVarComplex(pvApiCtx, piAddr))
		{
			printError(&sciErr, 0);
			return 0;
		}

		sciErr = getMatrixOfDouble(pvApiCtx, piAddr, &iRows, &iCols, &matData);
		if(sciErr.iErr)
		{
			printError(&sciErr, 0);
			return 0;
		}	 

		if (iCols!=2)
        {
            Scierror(999,"Invalid Argument\n");
            return 0;
        }

	    OrientationData = (double *)malloc(sizeof(double)*iRows);
	    MetricData = (double *)malloc(sizeof(double)*iRows);
	    LaplacianData = (int *)malloc(sizeof(int)*iRows);
	    ScaleData = (double *)malloc(sizeof(double)*iRows);

		for(int i = 0 ; i<iRows; i++)
		{			
		    OrientationData[i] = 0;
		    MetricData[i] = 0;
		    LaplacianData[i] = 0;
		    ScaleData[i] = 1.6;
		}

	    sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, iRows,2, matData);
	    if(sciErr.iErr)
	    {
	        printError(&sciErr, 0);
	        return 0;
	    }

	    sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 2, iRows,1, OrientationData);
	    if(sciErr.iErr)
	    {
	        printError(&sciErr, 0);
	        return 0;
	    }
	        
	    sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 3, iRows,1, MetricData);
	    if(sciErr.iErr)
	    {
	        printError(&sciErr, 0);
	        return 0;
	    }
	 
	    sciErr = createMatrixOfInteger32(pvApiCtx, nbInputArgument(pvApiCtx) + 4, iRows,1, LaplacianData);
	    if(sciErr.iErr)
	    {
	        printError(&sciErr, 0);
	        return 0;
	    }

	    sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 5, iRows,1, ScaleData);
	    if(sciErr.iErr)
	    {
	        printError(&sciErr, 0);
	        return 0;
	    }

	    createScalarInteger32(pvApiCtx,nbInputArgument(pvApiCtx) + 6, iRows);

	    for(int i=1;i<=6;i++)
	    {
	 		AssignOutputVariable(pvApiCtx, i) = nbInputArgument(pvApiCtx) + i;   	
	    }

		ReturnArguments(pvApiCtx);
		return 0;
	}
}