1 | initial version |
i'd propose a similar, but maybe easier approach: instead of generating a new, seperate python module (.so), embed your code into the existing cv2.so
make a new folder inside opencv/modules, containing your code:
opencv/modules/testcv
| CMakeLists.txt
|
+---include
| \---opencv2
| testcv.hpp // hpp, not h, please !
|
\---src
testcv.cpp
your code depends on opencv_core, opencv_imgcodecs, and opencv_highgui, so put the dependancies there:
set(the_description "my fancy cvtest")
ocv_define_module(cvtest opencv_imgproc opencv_core opencv_highgui WRAP python)
cmake <lots of args> <opencv_src>
make && make install
2 | No.2 Revision |
i'd propose a similar, but maybe easier approach: instead of generating a new, seperate python module (.so), embed your code into the existing cv2.so
make a new folder inside opencv/modules, containing your code:
opencv/modules/testcv
| CMakeLists.txt
|
+---include
| \---opencv2
| testcv.hpp // hpp, not h, please !
|
\---src
testcv.cpp
your code depends on opencv_core, opencv_imgcodecs, and opencv_highgui, so put the dependancies there:
set(the_description "my fancy cvtest")
ocv_define_module(cvtest opencv_imgproc opencv_core opencv_highgui WRAP python)
https://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html
cmake <lots of args> <opencv_src>
make && make install
3 | No.3 Revision |
i'd propose a similar, but maybe easier approach: instead of generating a new, seperate python module (.so), embed your code into the existing cv2.so
make a new folder inside opencv/modules, containing your code:
opencv/modules/testcv
| CMakeLists.txt
|
+---include
| \---opencv2
| testcv.hpp // hpp, not h, please !
|
\---src
testcv.cpp
your code depends on opencv_core, opencv_imgcodecs, and opencv_highgui, so put the dependancies there:
set(the_description "my fancy cvtest")
ocv_define_module(cvtest opencv_imgproc opencv_core opencv_highgui WRAP python)
https://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html
cmake <lots of args> <opencv_src>
make && make install
import cv2
t = cv2.testCV() # it's inside cv2 now!
t.TakeALook()
4 | No.4 Revision |
i'd propose a similar, but maybe easier approach: instead of generating a new, seperate python module (.so), embed your code into the existing cv2.so
make a new folder inside opencv/modules, containing your code:
opencv/modules/testcv
| CMakeLists.txt
|
+---include
| \---opencv2
| testcv.hpp // hpp, not h, please !
|
\---src
testcv.cpp
your code depends on opencv_core, opencv_imgcodecs, and opencv_highgui, so put the dependancies there:
set(the_description "my fancy cvtest")
ocv_define_module(cvtest opencv_imgproc opencv_core opencv_highgui WRAP python)
.
//testcv.hpp:
#include <opencv2/opencv.hpp>
namespace cv { // put it into cv2 namespace
CV_EXPORTS_W class TestCV
{
public:
CV_WRAP TestCV();
CV_WRAP void TakeALook();
};
}
.
//testcv.cpp
#include "testcv.hpp"
using namespace std;
using namespace cv;
TestCV::TestCV()
{
}
void TestCV::TakeALook()
{
Mat src=imread("a.jpg");
imshow("see!",src);
waitKey(0);
}
(along with your own code, now !)
https://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html
cmake <lots of args> <opencv_src>
make && make install
import cv2
t = cv2.testCV() # it's inside cv2 now!
t.TakeALook()
5 | No.5 Revision |
i'd propose a similar, but maybe easier approach: instead of generating a new, seperate python module (.so), embed your code into the existing cv2.so
make a new folder inside opencv/modules, containing your code:
opencv/modules/testcv
| CMakeLists.txt
|
+---include
| \---opencv2
| testcv.hpp // hpp, not h, please !
|
\---src
testcv.cpp
your code depends on opencv_core, opencv_imgcodecs, and opencv_highgui, so put the dependancies there:
set(the_description "my fancy cvtest")
ocv_define_module(cvtest opencv_imgproc opencv_core opencv_highgui WRAP python)
.
//testcv.hpp:
#include <opencv2/opencv.hpp>
namespace cv { // put it into cv2 namespace
// if you add your own namespace (inside cv2) here, it will be: cv2.myspace.TestCV() later
CV_EXPORTS_W class TestCV
{
public:
CV_WRAP TestCV();
CV_WRAP void TakeALook();
};
}
.
//testcv.cpp
#include "testcv.hpp"
using namespace std;
using namespace cv;
TestCV::TestCV()
{
}
void TestCV::TakeALook()
{
Mat src=imread("a.jpg");
imshow("see!",src);
waitKey(0);
}
(along with your own code, now !)
https://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html
cmake <lots of args> <opencv_src>
make && make install
import cv2
t = cv2.testCV() # it's inside cv2 now!
t.TakeALook()
6 | No.6 Revision |
i'd propose a similar, but maybe easier approach: instead of generating a new, seperate python module (.so), embed your code into the existing cv2.so
make a new folder inside opencv/modules, containing your code:
opencv/modules/testcv
| CMakeLists.txt
|
+---include
| \---opencv2
| testcv.hpp // hpp, not h, please !
|
\---src
testcv.cpp
your code depends on opencv_core, opencv_imgcodecs, and opencv_highgui, so put the dependancies there:
set(the_description "my fancy cvtest")
ocv_define_module(cvtest opencv_imgproc opencv_core opencv_highgui WRAP python)
.
//testcv.hpp:
#include <opencv2/opencv.hpp>
namespace cv { // put it into cv2 namespace
// if you add your own namespace (inside cv2) here, it will be: cv2.myspace.TestCV() later
CV_EXPORTS_W class TestCV
{
public:
CV_WRAP TestCV();
CV_WRAP void TakeALook();
};
}
.
//testcv.cpp
#include "testcv.hpp"
using namespace std;
using namespace cv;
TestCV::TestCV()
{
}
void TestCV::TakeALook()
{
Mat src=imread("a.jpg");
imshow("see!",src);
waitKey(0);
}
(along with your own code, now !)
https://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html
cmake <lots of args> <opencv_src>
make && make install
import cv2
t = cv2.testCV() # it's inside cv2 now!
t.TakeALook()