Ask Your Question
0

How to generate python wrapper using gen2.py

asked 2015-04-01 10:39:50 -0600

Gopi Krishnan gravatar image

In the OpenCV build location

opencv\sources\modules\python\src2 found gen2.py

Then ,try to generate python wrapper for the function "int sample(cv::Mat image,cv::Mat &out);" . It creates python object for "Mat" Datatypes in the wrappers,But can't convert python object to Mat for my called c++ source file.

Source Language - C++

/example.cpp/

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int sample(Mat image,Mat &out)
{
   cv::Mat thresh; 

    if(! image.data )                              
   {
       cout <<  "Could not open or find the image" << std::endl ;


   }
  cvtColor(image, out,COLOR_BGR2GRAY);// Wait for a keystroke in the window
    return 0;
}

This my Method ,It is possible to genearte Python Wrapper for below function using the gen2.py

int sample(cv::Mat image,cv::Mat &out);

Let me know the Possiblities ? and Results?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-04-12 20:48:17 -0600

Why not just make that a python function?

def sample(img, retImg): retImg = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) return retImg

edit flag offensive delete link more

Comments

Yes Sure!!, thanks will try it.

Gopi Krishnan gravatar imageGopi Krishnan ( 2015-04-20 02:26:09 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-04-01 10:39:50 -0600

Seen: 470 times

Last updated: Apr 01 '15