Advertisement
dan-masek

OpenCV Canny generated Python wrapper

Sep 28th, 2017
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.30 KB | None | 0 0
  1. static PyObject* pyopencv_cv_Canny(PyObject* , PyObject* args, PyObject* kw)
  2. {
  3.     using namespace cv;
  4.  
  5.     {
  6.     PyObject* pyobj_image = NULL;
  7.     Mat image;
  8.     PyObject* pyobj_edges = NULL;
  9.     Mat edges;
  10.     double threshold1=0;
  11.     double threshold2=0;
  12.     int apertureSize=3;
  13.     bool L2gradient=false;
  14.  
  15.     const char* keywords[] = { "image", "threshold1", "threshold2", "edges", "apertureSize", "L2gradient", NULL };
  16.     if( PyArg_ParseTupleAndKeywords(args, kw, "Odd|Oib:Canny", (char**)keywords, &pyobj_image, &threshold1, &threshold2, &pyobj_edges, &apertureSize, &L2gradient) &&
  17.         pyopencv_to(pyobj_image, image, ArgInfo("image", 0)) &&
  18.         pyopencv_to(pyobj_edges, edges, ArgInfo("edges", 1)) )
  19.     {
  20.         ERRWRAP2(cv::Canny(image, edges, threshold1, threshold2, apertureSize, L2gradient));
  21.         return pyopencv_from(edges);
  22.     }
  23.     }
  24.     PyErr_Clear();
  25.  
  26.     {
  27.     PyObject* pyobj_image = NULL;
  28.     UMat image;
  29.     PyObject* pyobj_edges = NULL;
  30.     UMat edges;
  31.     double threshold1=0;
  32.     double threshold2=0;
  33.     int apertureSize=3;
  34.     bool L2gradient=false;
  35.  
  36.     const char* keywords[] = { "image", "threshold1", "threshold2", "edges", "apertureSize", "L2gradient", NULL };
  37.     if( PyArg_ParseTupleAndKeywords(args, kw, "Odd|Oib:Canny", (char**)keywords, &pyobj_image, &threshold1, &threshold2, &pyobj_edges, &apertureSize, &L2gradient) &&
  38.         pyopencv_to(pyobj_image, image, ArgInfo("image", 0)) &&
  39.         pyopencv_to(pyobj_edges, edges, ArgInfo("edges", 1)) )
  40.     {
  41.         ERRWRAP2(cv::Canny(image, edges, threshold1, threshold2, apertureSize, L2gradient));
  42.         return pyopencv_from(edges);
  43.     }
  44.     }
  45.     PyErr_Clear();
  46.  
  47.     {
  48.     PyObject* pyobj_dx = NULL;
  49.     Mat dx;
  50.     PyObject* pyobj_dy = NULL;
  51.     Mat dy;
  52.     PyObject* pyobj_edges = NULL;
  53.     Mat edges;
  54.     double threshold1=0;
  55.     double threshold2=0;
  56.     bool L2gradient=false;
  57.  
  58.     const char* keywords[] = { "dx", "dy", "threshold1", "threshold2", "edges", "L2gradient", NULL };
  59.     if( PyArg_ParseTupleAndKeywords(args, kw, "OOdd|Ob:Canny", (char**)keywords, &pyobj_dx, &pyobj_dy, &threshold1, &threshold2, &pyobj_edges, &L2gradient) &&
  60.         pyopencv_to(pyobj_dx, dx, ArgInfo("dx", 0)) &&
  61.         pyopencv_to(pyobj_dy, dy, ArgInfo("dy", 0)) &&
  62.         pyopencv_to(pyobj_edges, edges, ArgInfo("edges", 1)) )
  63.     {
  64.         ERRWRAP2(cv::Canny(dx, dy, edges, threshold1, threshold2, L2gradient));
  65.         return pyopencv_from(edges);
  66.     }
  67.     }
  68.     PyErr_Clear();
  69.  
  70.     {
  71.     PyObject* pyobj_dx = NULL;
  72.     UMat dx;
  73.     PyObject* pyobj_dy = NULL;
  74.     UMat dy;
  75.     PyObject* pyobj_edges = NULL;
  76.     UMat edges;
  77.     double threshold1=0;
  78.     double threshold2=0;
  79.     bool L2gradient=false;
  80.  
  81.     const char* keywords[] = { "dx", "dy", "threshold1", "threshold2", "edges", "L2gradient", NULL };
  82.     if( PyArg_ParseTupleAndKeywords(args, kw, "OOdd|Ob:Canny", (char**)keywords, &pyobj_dx, &pyobj_dy, &threshold1, &threshold2, &pyobj_edges, &L2gradient) &&
  83.         pyopencv_to(pyobj_dx, dx, ArgInfo("dx", 0)) &&
  84.         pyopencv_to(pyobj_dy, dy, ArgInfo("dy", 0)) &&
  85.         pyopencv_to(pyobj_edges, edges, ArgInfo("edges", 1)) )
  86.     {
  87.         ERRWRAP2(cv::Canny(dx, dy, edges, threshold1, threshold2, L2gradient));
  88.         return pyopencv_from(edges);
  89.     }
  90.     }
  91.  
  92.     return NULL;
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement