Created
June 27, 2012 10:42
-
-
Save jayrambhia/3003247 to your computer and use it in GitHub Desktop.
Comparison between run time of SimpleCV, OpenCV(python) and OpenCV(C++) Boost::Python bindings.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PYTHON_VERSION = 2.7 | |
PYTHON_INCLUDE = /usr/include/python$(PYTHON_VERSION) | |
# location of the Boost Python include files and library | |
BOOST_INC = /usr/include | |
BOOST_LIB = /usr/lib | |
# compile mesh classes | |
TARGET = opencvtest | |
$(TARGET).so: $(TARGET).o | |
g++ -shared -Wl,--export-dynamic $(TARGET).o -L$(BOOST_LIB) -lboost_python -L/usr/lib/python$(PYTHON_VERSION)/config -lpython$(PYTHON_VERSION) -o $(TARGET).so `pkg-config --libs opencv` `pkg-config --cflags opencv` | |
$(TARGET).o: $(TARGET).cpp | |
g++ -I$(PYTHON_INCLUDE) -I$(BOOST_INC) -fPIC -c $(TARGET).cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
def foo(): | |
image = "/home/jay/Pictures/python.jpg" | |
t = time.time() | |
from cv2.cv import LoadImage | |
img = LoadImage(image) | |
t1 = time.time() | |
from SimpleCV import Image | |
img1 = Image(image) | |
t2 = time.time() | |
from opencvtest import load | |
img3 = load(image) | |
t3 = time.time() | |
print t1-t | |
print t2-t1 | |
print t3-t2 | |
foo() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<opencv2/highgui/highgui.hpp> | |
using namespace cv; | |
using namespace std; | |
int load(string filename) | |
{ | |
Mat img = imread(filename,CV_LOAD_IMAGE_COLOR); | |
//imshow("opencvtest",img); | |
//waitKey(0); | |
return 1; | |
} | |
//#include<boost/python/detail/wrap_python.hpp> | |
#include<boost/python.hpp> | |
using namespace boost::python; | |
BOOST_PYTHON_MODULE(opencvtest) | |
{ | |
def("load",load); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "Compiling" | |
make | |
echo "Please change the image filename in opencv_load.py" | |
python opencv_load.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment