Commit 60079da9 authored by bliss administrator's avatar bliss administrator
Browse files

build opencv extension;

but opencv code has been commented for the moment, since
it doesn't work on Debian 6
parent f3779eff
%Import qt/qtmod.sip
%Module opencv 0
%Doc
<h1>Class qtTools</h1>
<p>
This class provide a transformation between Opencv image and QImage (Only in 8 bits for now)
</p>
%End
%MappedType IplImage
{
%TypeHeaderCode
// Include the library interface to the type being mapped.
#include <opencv/cxcore.h>
#include "swig_opencv_image.h"
%End
%ConvertToTypeCode
// See if we are just being asked to check the type of the Python
// object.
if (sipIsErr == NULL)
{
IplImage *aBuffer;
return SWIG_ConvertPtr(sipPy,(void **)&aBuffer,SWIG_IplImageInfo(), 0) != -1;
}
IplImage *anImage;
SWIG_ConvertPtr(sipPy,(void **)&anImage,SWIG_IplImageInfo(), 0);
// Return the instance on the heap.
*sipCppPtrV = anImage;
// Apply the normal transfer.
// return sipGetState(sipTransferObj);
return 0;
%End
%ConvertFromTypeCode
PyObject *anPyImage = SWIG_NewPointerObj(sipCpp,SWIG_IplImageInfo(),1);
// Return the Python Image.
return anPyImage;
%End
};
%MappedType CvMat
{
%TypeHeaderCode
// Include the library interface to the type being mapped.
#include <opencv/cxcore.h>
#include "swig_opencv_image.h"
%End
%ConvertToTypeCode
// See if we are just being asked to check the type of the Python
// object.
if (sipIsErr == NULL)
{
CvMat *aBuffer;
return SWIG_ConvertPtr(sipPy,(void **)&aBuffer,SWIG_CvMatInfo(), 0) != -1;
}
CvMat *anImage;
SWIG_ConvertPtr(sipPy,(void **)&anImage,SWIG_CvMatInfo(), 0);
// Return the instance on the heap.
*sipCppPtrV = anImage;
// Apply the normal transfer.
// return sipGetState(sipTransferObj);
return 0;
%End
%ConvertFromTypeCode
PyObject *anPyImage = SWIG_NewPointerObj(sipCpp,SWIG_CvMatInfo(),1);
// Return the Python Image.
return anPyImage;
%End
};
class qtTools
{
%TypeHeaderCode
#include <opencv_qtTools.h>
%End
public :
static QImage getQImageFromImageOpencv(const CvMat*);
static CvMat* getImageOpencvFromQImage(const QImage*);
static QImage convertI420Data2YUV(const char *data,int width,int height);
};
......@@ -10,11 +10,11 @@ from Qub.Objects.QubDrawingEvent import QubModifyAbsoluteAction
from Qub.CTools import pixmaptools
try:
from opencv import cv
from Qub.CTools.opencv import qtTools
except ImportError:
cv = None
#try:
# from opencv import cv
# from Qub.CTools.opencv import qtTools
#except ImportError:
cv = None
##@defgroup DrawingCanvasTools Low level objects drawing
#@brief this is the group of all vector objects which can be put in a simple QCanvas.
......
......@@ -9,12 +9,12 @@ try:
except ImportError:
qttools = None
try:
from opencv import cv
from Qub.CTools import opencv
except ImportError :
cv = None
opencv = None
#try:
# from opencv import cv
# from Qub.CTools import opencv
#except ImportError :
cv = None
opencv = None
import numpy
##@brief This class is use to decompress standard data -> image.
......
import sys
import numpy
import qt
from opencv import cv
from Qub.CTools.opencv import qtTools
#from opencv import cv
#from Qub.CTools.opencv import qtTools
try:
from Qub.CTools.qttools import QubImage
except ImportError:
......@@ -1345,13 +1345,19 @@ class _pad_button(qt.QPushButton) :
self.parent().show()
self.stopButton.hide()
if old_scale < 1. :
imageOpencv = qtTools.getImageOpencvFromQImage(tmp_image)
destImage = cv.cvCreateImage(cv.cvSize(int(old_scale * tmp_image.width()),
int(old_scale * tmp_image.height())),
imageOpencv.depth,imageOpencv.nChannels)
cv.cvResize(imageOpencv,destImage,cv.CV_INTER_CUBIC)
self.__padInUse = qtTools.getQImageFromImageOpencv(destImage)
#imageOpencv = qtTools.getImageOpencvFromQImage(tmp_image)
#destImage = cv.cvCreateImage(cv.cvSize(int(old_scale * tmp_image.width()),
# int(old_scale * tmp_image.height())),
# imageOpencv.depth,imageOpencv.nChannels)
#
#cv.cvResize(imageOpencv,destImage,cv.CV_INTER_CUBIC)
#self.__padInUse = qtTools.getQImageFromImageOpencv(destImage)
if hasattr(tmp_image, "scaled"):
self.__padInUse = tmp_image.scaled(int(old_scale * tmp_image.width()),
int(old_scale * tmp_image.height()))
else:
self.__padInUse = tmp_image.smoothScale(int(old_scale * tmp_image.width()),
int(old_scale * tmp_image.height()))
self.__padInUse.setAlphaBuffer(True)
else :
self.__padInUse = tmp_image
......
......@@ -86,6 +86,13 @@ pixmaptools_module = Extension(name = "Qub.CTools/pixmaptools",
include_dirs = ['Qub/CTools/pixmaptools', numpy.get_include(), qt_inc_dir],
library_dirs = [qt_lib_dir])
opencv_module = Extension(name = "Qub.CTools/opencv",
sources = ["Qub/CTools/opencv/%s.sip" % (QT3 and "opencv_qt3" or "opencv_qt4")]+glob.glob('Qub/CTools/opencv/*.cpp'),
extra_compile_args = extra_compile_args,
extra_link_args = extra_link_args+['-l'+qt_lib, '-lcv'],
include_dirs = ['Qub/CTools/opencv', numpy.get_include(), qt_inc_dir],
library_dirs = [qt_lib_dir])
setup(name = "Qub",version = "1.0",
description = "Qub is a library providing data display tools for PyQt apps",
......@@ -93,5 +100,6 @@ setup(name = "Qub",version = "1.0",
packages = ["Qub", "Qub.CTools", "Qub.Data", "Qub.Data.Plug", "Qub.Data.Source", "Qub.Data.StreamIO", "Qub.Data.Scale", "Qub.Data.Class", "Qub.Icons", "Qub.Objects", "Qub.Objects.Mosaic", "Qub.Plugins", "Qub.Print", "Qub.Tools", "Qub.Widget", "Qub.Widget.DataSource", "Qub.Widget.Graph"],
package_data = {"Qub.Icons":["IconsLibrary/*"]},
ext_modules=[polygone_module,dataresize_module,mar345_module,pixmaptools_module, qttools_module],
ext_modules=[polygone_module,dataresize_module,mar345_module,pixmaptools_module, qttools_module,opencv_module],
cmdclass={'build_ext': my_own_build_ext})
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment