How to use cv::VideoCapture on wxThread?

This forum is reserved for everything you want to talk about. It could be about programming, opinions, open source programs, development in general, or just cool stuff to share!
Post Reply
Jaeheon Chung
In need of some credit
In need of some credit
Posts: 2
Joined: Fri Dec 02, 2011 12:32 am

How to use cv::VideoCapture on wxThread?

Post by Jaeheon Chung » Fri Dec 02, 2011 1:01 am

Hi,

Is it possible to use cv::VideoCapture on wxThread?

Actually, I already tested cv::VideoCapture function on wxFrame. and then confirmed result.

However, it didn't work on wxThread.

I guess the funcion which cv::VideoCapture can't operate on wxThread.

please answer to the question.

below is my source code and I use OpenCv 2.3.1, wxWidgets 2.9.2 and Visual Studio 10 express under Win7.

wxThread::ExitCode CleaningThread::Entry()
{
cv::VideoCapture capture(0);
if(!capture.isOpened())
return NULL;

bool stop(false);
cv::Mat cvImg;
cv::Mat canny;
cv::namedWindow("Img");

capture.read(cvImg);

while(!stop)
{
if(!capture.read(cvImg))
break;

if(cvImg.channels() == 3)
cv::cvtColor(cvImg, canny, CV_BGR2GRAY);

cv::Canny(canny, canny, 100, 200);
cv::threshold(canny, canny, 128, 255, cv::THRESH_BINARY_INV);

cv::imshow("Img", canny);
if(cv::waitKey(100) >= 0)
stop = true;
}

capture.release();

return NULL;
}

robocyte
In need of some credit
In need of some credit
Posts: 7
Joined: Sun Nov 13, 2011 9:12 pm

Re: How to use cv::VideoCapture on wxThread?

Post by robocyte » Fri Dec 02, 2011 5:49 pm

Hi,

it actually is possible! You're lucky, a couple of days ago I revisited wxOpenCv by Larry Lart.
For practicing purposes I decided to implement Larry's program using the newest versions of OpenCV and wxWidgets, just check my Google Code project page:

WxRoboCV

It builds fine and I can capture my webcam feed using a separate thread (using wxThreadHelper to be exact) and display it in a wxPanel.
You have to be warned though: it's still at an early stage, missing a lot of features, all of the icons etc... I will try to finish it within the next couple of days! For now, there is no pre-built executable available for download, so if you want to try out my program you have to build it (Visual Studio 2010 project files are included).

Jaeheon Chung
In need of some credit
In need of some credit
Posts: 2
Joined: Fri Dec 02, 2011 12:32 am

Re: How to use cv::VideoCapture on wxThread?

Post by Jaeheon Chung » Mon Dec 05, 2011 12:16 pm

Thank you for your answer..

I try to use your recommanded solution from svn..

In the solution, however, the property setting for solution such as path, library files and options was not prepared.

So, I set up the path and then try to build the solution.

However, I saw the build failed result due to its library link error LNK 2019.

I wonder your wxWidgets's version.

below is my building result...


1>------ Rebuild All started: Project: WxRoboCV, Configuration: Debug Win32 ------
1> WxRoboCV_GUI.cpp
1> WxRoboCV.cpp
1> MainFrame.cpp
1> Generating Code...
1>MainFrame.obj : error LNK2019: unresolved external symbol "public: void __thiscall wxAuiManager::Update(void)" ([email protected]@@QAEXXZ) referenced in function "public: __thiscall MainFrame::MainFrame(class wxWindow *)" ([email protected]@[email protected]@@@Z)
1>WxRoboCV_GUI.obj : error LNK2001: unresolved external symbol "public: void __thiscall wxAuiManager::Update(void)" ([email protected]@@QAEXXZ)
1>MainFrame.obj : error LNK2019: unresolved external symbol "public: void __thiscall wxAuiManager::SetFlags(unsigned int)" ([email protected]@@[email protected]) referenced in function "public: __thiscall MainFrame::MainFrame(class wxWindow *)" ([email protected]@[email protected]@@@Z)
1>WxRoboCV_GUI.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall wxAuiManager::~wxAuiManager(void)" ([email protected]@[email protected]) referenced in function [email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@[email protected]$0
1>WxRoboCV_GUI.obj : error LNK2019: unresolved external symbol "public: bool __thiscall wxAuiManager::AddPane(class wxWindow *,class wxAuiPaneInfo const &)" ([email protected]@@[email protected]@[email protected]@@Z) referenced in function "public: __thiscall MainFrame_base::MainFrame_base(class wxWindow *,int,class wxString const &,class wxPoint const &,class wxSize const &,long)" ([email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@[email protected])
1>WxRoboCV_GUI.obj : error LNK2019: unresolved external symbol "public: bool __thiscall wxAuiToolBar::Realize(void)" ([email protected]@@QAE_NXZ) referenced in function "public: __thiscall MainFrame_base::MainFrame_base(class wxWindow *,int,class wxString const &,class wxPoint const &,class wxSize const &,long)" ([email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@[email protected])
1>WxRoboCV_GUI.obj : error LNK2019: unresolved external symbol "public: class wxAuiToolBarItem * __thiscall wxAuiToolBar::AddTool(int,class wxString const &,class wxBitmap const &,class wxBitmap const &,enum wxItemKind,class wxString const &,class wxString const &,class wxObject *)" ([email protected]@@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z) referenced in function "public: __thiscall MainFrame_base::MainFrame_base(class wxWindow *,int,class wxString const &,class wxPoint const &,class wxSize const &,long)" ([email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@[email protected])
1>WxRoboCV_GUI.obj : error LNK2019: unresolved external symbol "public: __thiscall wxAuiToolBar::wxAuiToolBar(class wxWindow *,int,class wxPoint const &,class wxSize const &,long)" ([email protected]@[email protected]@@[email protected]@[email protected]@[email protected]) referenced in function "public: __thiscall MainFrame_base::MainFrame_base(class wxWindow *,int,class wxString const &,class wxPoint const &,class wxSize const &,long)" ([email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@[email protected])
1>WxRoboCV_GUI.obj : error LNK2019: unresolved external symbol "public: void __thiscall wxAuiManager::SetManagedWindow(class wxWindow *)" ([email protected]@@[email protected]@@Z) referenced in function "public: __thiscall MainFrame_base::MainFrame_base(class wxWindow *,int,class wxString const &,class wxPoint const &,class wxSize const &,long)" ([email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@[email protected])
1>WxRoboCV_GUI.obj : error LNK2019: unresolved external symbol "public: __thiscall wxAuiManager::wxAuiManager(class wxWindow *,unsigned int)" ([email protected]@[email protected]@@[email protected]) referenced in function "public: __thiscall MainFrame_base::MainFrame_base(class wxWindow *,int,class wxString const &,class wxPoint const &,class wxSize const &,long)" ([email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@[email protected])
1>WxRoboCV_GUI.obj : error LNK2019: unresolved external symbol "public: __thiscall wxAuiPaneButtonArray::~wxAuiPaneButtonArray(void)" ([email protected]@[email protected]) referenced in function [email protected]@[email protected]$0
1>WxRoboCV_GUI.obj : error LNK2019: unresolved external symbol "public: bool __thiscall wxAuiPaneInfo::IsValid(void)const " ([email protected]@@QBE_NXZ) referenced in function "public: class wxAuiPaneInfo & __thiscall wxAuiPaneInfo::DefaultPane(void)" ([email protected]@@[email protected])
1>WxRoboCV_GUI.obj : error LNK2019: unresolved external symbol "public: class wxAuiPaneButtonArray & __thiscall wxAuiPaneButtonArray::operator=(class wxAuiPaneButtonArray const &)" ([email protected]@[email protected]@@Z) referenced in function "public: __thiscall wxAuiPaneInfo::wxAuiPaneInfo(class wxAuiPaneInfo const &)" ([email protected]@[email protected]@@Z)
1>WxRoboCV_GUI.obj : error LNK2019: unresolved external symbol "public: void __thiscall wxAuiManager::UnInit(void)" ([email protected]@@QAEXXZ) referenced in function "public: virtual __thiscall MainFrame_base::~MainFrame_base(void)" ([email protected]@[email protected])
1>D:\000_RnD\001_Software_CPP\0006_CleaningFramework\temp\VS2010\Debug\WxRoboCV.exe : fatal error LNK1120: 13 unresolved externals
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========


robocyte wrote:Hi,

it actually is possible! You're lucky, a couple of days ago I revisited wxOpenCv by Larry Lart.
For practicing purposes I decided to implement Larry's program using the newest versions of OpenCV and wxWidgets, just check my Google Code project page:

WxRoboCV

It builds fine and I can capture my webcam feed using a separate thread (using wxThreadHelper to be exact) and display it in a wxPanel.
You have to be warned though: it's still at an early stage, missing a lot of features, all of the icons etc... I will try to finish it within the next couple of days! For now, there is no pre-built executable available for download, so if you want to try out my program you have to build it (Visual Studio 2010 project files are included).

robocyte
In need of some credit
In need of some credit
Posts: 7
Joined: Sun Nov 13, 2011 9:12 pm

Re: How to use cv::VideoCapture on wxThread?

Post by robocyte » Sun Dec 11, 2011 12:30 pm

Hi Jaeheon,

Sorry for my late answer!
I wonder your wxWidgets's version.
I'm building wx as a monolithic static library, this is my building procedure:

Open Visual Studio's command prompt and navigate to the "build\msw" folder inside your wxWidgets installation, in my case:

"cd D:\Design\Dev\- Libraries -\wxWidgets_SVN\build\msw"

Then build by entering

"nmake -f makefile.vc MONOLITHIC=1 SHARED=0 BUILD=release USE_OPENGL=1 RUNTIME_LIBS=static"

Btw I'm using current SVN versions of both wxWidgets and OpenCV, see InstallationNotes on my google code page.

Post Reply