Yes, I did integration opencv/wxwidgets in a fairly complex project.
What exactly are u interested in ? GUI integration ? image conversion ?
camera view integration? Let me know and i will show u what I did.
Larry
give u some samples.
"Franco Amato" wrote:
> Hi people.
> Does someone have experience programming with OpenCV library and wxWidgets
> together?
> If yes can I have an example to integrate OpenCV in a wxWidgets frame?
> Best Regards
> Frank
>
> ------=_Part_15773_1120962.1146065715751
> Content-Type: text/html; charset=ISO-8859-1
> Content-Transfer-Encoding: quoted-printable
> X-Google-AttachSize: 211
>
> Hi people.<br>Does someone have experience programming with OpenCV library and wxWidgets together?<br>If yes can I have an example to integrate OpenCV in a wxWidgets frame?<br>Best Regards<br>Frank<br><br>
>
> ------=_Part_15773_1120962.1146065715751--
>Yes, I did integration opencv/wxwidgets in a fairly complex project.
>What exactly are u interested in ? GUI integration ? image conversion ?
>camera view integration? Let me know and i will show u what I did.
>
>
Oh, I am very interested too!
Was your project tested on both windows and linux?
I would very much like some sample that shows how you integrated the
output from a videocam into a wx frame.
Were you able to show both the pure camera output stream and some
manipulated videostream?
When was this done, what version of openCV? I have looked a bit on
OpenCV, but I was a bit worried about their Linux support, it seemed
like the development had focused mostly on windows. Also I got the
impression that the development in general was very slow, and I was
afraid of digging in to a dying a project...
What was/is your opinion on openCV? Did you try alternatives?
regards,
Kristian ( debian user )
---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-u...@lists.wxwidgets.org
For additional commands, e-mail: wx-use...@lists.wxwidgets.org
I also had many headaches trying to integrate gocr (for character and
bar code recognition) in this package. However I am not very happy with
the results ... integration worked fine (after editing many thousands
of lines of code I managed to encapsulate the c code in c++ and then
get it working with opencv and wxwidgets) however it didn't gave good
results on webcam resolution :( .. and it's also too slow. So here I
am, still digging for a good implementation.
Larry
My project does pretty much all that. See
http://larryo.org/work/robotics/chorg.html - sorry there not much info
there yet and pictures are a bit outdated (more then a year old).
And, yes, I did manage to compile it on linux (redhat) to ... more then
a year ago. True is I had some problems but not with the opencv
integration but the webcam drives weren't really there like they
should.
I used wxwidgets 2.4 at the time ... I recon now with 2.6 there must be
a more elegant way to handle the conversion . For camera integration in
linux you can see the link I provide bellow my approach at the time(not
100% that was the one that worked or I re-write it meanwhile). Look in
Ccamera.cpp in between defines for win32_larry and else(linux).
However I think with the new opencv version a more elegant approach can
be done. It much depends on your needs as well ... I need full control
at frame level synchronized with the rest of the threads.
Sorry for the mess in the code, I don't have other another cleaner
example at the moment - and I have plenty of other "more" grey
areas in my projects to worrie about at the moment :) Perhaps it wont
be a bad idea to create sample on how to use these together whenever I
get some time.
Generally, I am happy with opencv. True, the development it's a bit
slow but is not dead yet :).
Let me know if I can be any further help
Larry
Links:
http://larryo.org/web/work/robotics/chorg/camera.cpp
http://larryo.org/web/work/robotics/chorg/camera.h
http://larryo.org/web/work/robotics/chorg/mainframe.cpp
http://larryo.org/web/work/robotics/chorg/mainframe.h
http://larryo.org/web/work/robotics/chorg/camview.cpp
http://larryo.org/web/work/robotics/chorg/camview.h
A code extras:
******************************frame****************
In the frame you construct your cam viewer:
// build cam canvas
m_pCamView = new CCamView( panel1, wxPoint(5,15), wxSize(354, 256) );
*******************************window******************
then in CcamView (which extends wxWindow ) I do(first two methods are
just used to handle the drawing in window by wxwidgets, the third
method does the actual conversion from iplimage to bitmap) :
////////////////////////////////////////////////////////////////////
// Method: OnPaint
// Class: CCamView
// Purose: on paint event
// Input: reference to paint event
// Output: nothing
////////////////////////////////////////////////////////////////////
void CCamView::OnPaint( wxPaintEvent& event )
{
wxPaintDC dc(this);
Draw( dc );
}
////////////////////////////////////////////////////////////////////
// Method: Draw
// Class: CCamView
// Purose: camera drawing
// Input: reference to dc
// Output: nothing
////////////////////////////////////////////////////////////////////
void CCamView::Draw( wxDC& dc )
{
// check if dc available
if( !dc.Ok( ) ){ return; }
m_bDrawing = true;
dc.BeginDrawing();
int x,y,w,h;
dc.GetClippingBox( &x, &y, &w, &h );
// if there is a new image to draw
if( m_bNewImage )
{
dc.DrawBitmap( m_pBitmap, x, y );
m_bNewImage = false;
} else
{
// draw inter frame ?
}
dc.EndDrawing();
m_bDrawing = false;
return;
}
// I call this method from the camera object to do the conversion to
bitmap so I can display with wxwidgets - it might be a better way
////////////////////////////////////////////////////////////////////
// Method: DrawCam
// Class: CCamView
// Purose: convert ipl image and handle other drawings
// Input: ipl image pointer
// Output: nothing
////////////////////////////////////////////////////////////////////
void CCamView::DrawCam( IplImage* pImg )
{
if( pImg )
{
unsigned char *rawData;
CvSize roiSize;
int step = 0;
cvGetRawData( pDstImg, &rawData, &step, &roiSize );
wxImage pWxImg = wxImage( 640,480, rawData, TRUE );
m_pBitmap = wxBitmap( pWxImg.Scale(m_nWidth, m_nHeight) );
m_bNewImage = true;
m_bDrawing = false;
Refresh( FALSE );
cvReleaseImage( &pDstImg );
}
}
************************** Camera call*********************************
pFrame = cvQueryFrame( m_pCapture );
if( pFrame )
{
// if no video image
if( !m_pVideoImg )
{
cvReleaseImage( &m_pVideoImg );
m_pVideoImg = cvCreateImage( cvSize( m_nWidth, m_nHeight ), 8, 3 );
}
if( pFrame->origin == 1 )
{
//cvFlip( pFrame, m_pVideoImg, 0 );
//cvCvtColor( m_pVideoImg, m_pVideoImg, CV_BGR2RGB );
cvConvertImage( pFrame, m_pVideoImg, CV_CVTIMG_FLIP |
CV_CVTIMG_SWAP_RB );
} else
{
cvCopy( pFrame, m_pVideoImg, 0 );
}
m_pCameraView->DrawCam( m_pVideoImg );
************************* frame camera control panel
hack***************
This is a hack I did to get the camera control panel in wxwidgets -
only for windows
////////////////////////////////////////////////////////////////////
// Method: On Video Source
// Class: CMainFrame
// Purose: when video source menu option selected
// Input: reference to event
// Output: nothing
////////////////////////////////////////////////////////////////////
void CMainFrame::OnVideoSource( wxCommandEvent& event )
{
CCamView *pView = GetCameraView();
// for widnows do this
#ifdef _WINDOWS
// hack to get the windows handler
typedef struct CvCaptureCAM_VFW
{
void* vtable;
CAPDRIVERCAPS caps;
HWND capWnd;
VIDEOHDR* hdr;
DWORD fourcc;
HIC hic;
IplImage* rgb_frame;
IplImage frame;
} CvCaptureCAM_VFW;
CvCapture* ptest = pView->m_pCamera->m_pCapture;
CvCaptureCAM_VFW* p = (CvCaptureCAM_VFW*) ptest;
capDlgVideoSource( p->capWnd );
#elif _LINUX
// else ... TODO
#endif
return;
}
////////////////////////////////////////////////////////////////////
// Method: On Video Format
// Class: CMainFrame
// Purose: when video format menu option selected
// Input: reference to event
// Output: nothing
////////////////////////////////////////////////////////////////////
void CMainFrame::OnVideoFormat( wxCommandEvent& event )
{
CCamView *pView = GetCameraView();
// for widnows do this
#ifdef _WINDOWS
// hack to get the windows handler
typedef struct CvCaptureCAM_VFW
{
void* vtable;
CAPDRIVERCAPS caps;
HWND capWnd;
VIDEOHDR* hdr;
DWORD fourcc;
HIC hic;
IplImage* rgb_frame;
IplImage frame;
} CvCaptureCAM_VFW;
CvCapture* ptest = pView->m_pCamera->m_pCapture;
CvCaptureCAM_VFW* p = (CvCaptureCAM_VFW*) ptest;
capDlgVideoFormat( p->capWnd );
#elif _LINUX
// else ... TODO
#endif
return;
}
http://larryo.org/work/robotics/chorg/camera.cpp
http://larryo.org/work/robotics/chorg/camera.h
http://larryo.org/work/robotics/chorg/mainframe.cpp
http://larryo.org/work/robotics/chorg/mainframe.h
http://larryo.org/work/robotics/chorg/camview.cpp
http://larryo.org/work/robotics/chorg/camview.h
>Aaa, by the way Kristian, do you know any other alternatives?
>
I haven't looked much into this but in my googling I stumbled across:
vigra:
http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/
/ Kristian
Well, I meant the way the opencv team makes new releases, bug fixes,
optimizations, etc. as being a bit slow. Otherwise I am fairly happy
with opencv... as far. It's a good tool to make your way around with.
And after all it's open source so if you aren't happy with the
performance you can dig into it and do it better.
Yes, it does run under windows as primary target. I did compile it on
linux as well more then a year ago but since then I focused more to get
the functionality done and did most of the work around windows.
Yes, I used wx2.4. I only recently got the wx2.6 installed but didn't
got yet the time to compile the thing and check for any
incompatibilities. But I am sure that it will work.
Don't worry, ask and if I have the time and the answer I will gladly
help.
Larry