summaryrefslogtreecommitdiff
path: root/sci_gateway/cpp/opencv_imabsdiff.cpp
blob: becb7735ece70bb7eca37bab99c1170467374e77 (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
/********************************************************
Function   :imabsdiff
Syntax     :C=imabsdiff(A,B)
Author     : Tess  Zacharias
********************************************************/

#include <numeric>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/opencv.hpp"
#include <iostream>
#include "string.h"
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_imabsdiff(char *fname, unsigned long fname_len)
  {

    SciErr sciErr;
    Mat A,B,C;
    CheckInputArgument(pvApiCtx, 2, 2);
    CheckOutputArgument(pvApiCtx, 1, 1) ;
    retrieveImage(A,1);
    retrieveImage(B,2);
    Size s1=A.size();
    Size s2=B.size();
    if(s1!=s2)
      { 
        sciprint("\nBoth input should be same size");
        return 0;
      }
    absdiff(A,B,C);
    int temp = nbInputArgument(pvApiCtx) + 1;
    string tempstring = type2str(C.type());
    char *checker;
    checker = (char *)malloc(tempstring.size() + 1);
    memcpy(checker, tempstring.c_str(), tempstring.size() + 1);
    returnImage(checker,C,1);
    free(checker); 
    AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
    ReturnArguments(pvApiCtx);
    return 0;
  }
}