我有一项任务,必须为现有的 C++ 库编写 Python 绑定。由于 SWIG 不仅支持 Python,还支持 Java 和 Perl 等语言,因此我使用 SWIG。我对 SWIG 比较陌生,所以我有疑问。我希望我的 python 库能够在 Python 2.7 和 Python 3.x 下受支持。但我不知道如何做到这一点。所以如果有人可以建议我。任何帮助,将不胜感激。如果您愿意,可以向我询问更多详细信息。
到目前为止我已经尝试过的。
这是我的代码文件。
/* example.c file */
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int my_mod(int n, int m) {
return n % m;
}
int sieve(int number) {
int* arr = malloc(sizeof (int) * (number + 10));
int* prime = malloc(sizeof (int) * (number + 10));
/* printf("Size of arr: %lu", sizeof(arr));
printf("Size of int: %lu", sizeof(int)); */ …Run Code Online (Sandbox Code Playgroud) 我最近在我的ubuntu 14.10系统中安装了OpenCv,我正在运行一个程序并且在功能上cv::BackgroundSubtractorMOG2我遇到了错误.
错误是cannot declare variable ‘bg’ to be of abstract type ‘cv::BackgroundSubtractorMOG2’我遇到此错误的原因
我的代码示例
int main(int argc, char *argv[]) {
Mat frame;
Mat back;
Mat front;
vector<pair<Point,double> > hand_middle;
VideoCapture cap(0);
BackgroundSubtractorMOG2 bg; //Here I am facing error
bg.set("nmixtures",3);
bg.set("detectShadows",false);
//Rest of my code
return 0;
}
Run Code Online (Sandbox Code Playgroud)