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 »

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 »

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 »

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)" (?Update@wxAuiManager@@QAEXXZ) referenced in function "public: __thiscall MainFrame::MainFrame(class wxWindow *)" (??0MainFrame@@QAE@PAVwxWindow@@@Z)
1>WxRoboCV_GUI.obj : error LNK2001: unresolved external symbol "public: void __thiscall wxAuiManager::Update(void)" (?Update@wxAuiManager@@QAEXXZ)
1>MainFrame.obj : error LNK2019: unresolved external symbol "public: void __thiscall wxAuiManager::SetFlags(unsigned int)" (?SetFlags@wxAuiManager@@QAEXI@Z) referenced in function "public: __thiscall MainFrame::MainFrame(class wxWindow *)" (??0MainFrame@@QAE@PAVwxWindow@@@Z)
1>WxRoboCV_GUI.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall wxAuiManager::~wxAuiManager(void)" (??1wxAuiManager@@UAE@XZ) referenced in function __unwindfunclet$??0MainFrame_base@@QAE@PAVwxWindow@@HABVwxString@@ABVwxPoint@@ABVwxSize@@J@Z$0
1>WxRoboCV_GUI.obj : error LNK2019: unresolved external symbol "public: bool __thiscall wxAuiManager::AddPane(class wxWindow *,class wxAuiPaneInfo const &)" (?AddPane@wxAuiManager@@QAE_NPAVwxWindow@@ABVwxAuiPaneInfo@@@Z) referenced in function "public: __thiscall MainFrame_base::MainFrame_base(class wxWindow *,int,class wxString const &,class wxPoint const &,class wxSize const &,long)" (??0MainFrame_base@@QAE@PAVwxWindow@@HABVwxString@@ABVwxPoint@@ABVwxSize@@J@Z)
1>WxRoboCV_GUI.obj : error LNK2019: unresolved external symbol "public: bool __thiscall wxAuiToolBar::Realize(void)" (?Realize@wxAuiToolBar@@QAE_NXZ) referenced in function "public: __thiscall MainFrame_base::MainFrame_base(class wxWindow *,int,class wxString const &,class wxPoint const &,class wxSize const &,long)" (??0MainFrame_base@@QAE@PAVwxWindow@@HABVwxString@@ABVwxPoint@@ABVwxSize@@J@Z)
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 *)" (?AddTool@wxAuiToolBar@@QAEPAVwxAuiToolBarItem@@HABVwxString@@ABVwxBitmap@@1W4wxItemKind@@00PAVwxObject@@@Z) referenced in function "public: __thiscall MainFrame_base::MainFrame_base(class wxWindow *,int,class wxString const &,class wxPoint const &,class wxSize const &,long)" (??0MainFrame_base@@QAE@PAVwxWindow@@HABVwxString@@ABVwxPoint@@ABVwxSize@@J@Z)
1>WxRoboCV_GUI.obj : error LNK2019: unresolved external symbol "public: __thiscall wxAuiToolBar::wxAuiToolBar(class wxWindow *,int,class wxPoint const &,class wxSize const &,long)" (??0wxAuiToolBar@@QAE@PAVwxWindow@@HABVwxPoint@@ABVwxSize@@J@Z) referenced in function "public: __thiscall MainFrame_base::MainFrame_base(class wxWindow *,int,class wxString const &,class wxPoint const &,class wxSize const &,long)" (??0MainFrame_base@@QAE@PAVwxWindow@@HABVwxString@@ABVwxPoint@@ABVwxSize@@J@Z)
1>WxRoboCV_GUI.obj : error LNK2019: unresolved external symbol "public: void __thiscall wxAuiManager::SetManagedWindow(class wxWindow *)" (?SetManagedWindow@wxAuiManager@@QAEXPAVwxWindow@@@Z) referenced in function "public: __thiscall MainFrame_base::MainFrame_base(class wxWindow *,int,class wxString const &,class wxPoint const &,class wxSize const &,long)" (??0MainFrame_base@@QAE@PAVwxWindow@@HABVwxString@@ABVwxPoint@@ABVwxSize@@J@Z)
1>WxRoboCV_GUI.obj : error LNK2019: unresolved external symbol "public: __thiscall wxAuiManager::wxAuiManager(class wxWindow *,unsigned int)" (??0wxAuiManager@@QAE@PAVwxWindow@@I@Z) referenced in function "public: __thiscall MainFrame_base::MainFrame_base(class wxWindow *,int,class wxString const &,class wxPoint const &,class wxSize const &,long)" (??0MainFrame_base@@QAE@PAVwxWindow@@HABVwxString@@ABVwxPoint@@ABVwxSize@@J@Z)
1>WxRoboCV_GUI.obj : error LNK2019: unresolved external symbol "public: __thiscall wxAuiPaneButtonArray::~wxAuiPaneButtonArray(void)" (??1wxAuiPaneButtonArray@@QAE@XZ) referenced in function __unwindfunclet$??0wxAuiPaneInfo@@QAE@XZ$0
1>WxRoboCV_GUI.obj : error LNK2019: unresolved external symbol "public: bool __thiscall wxAuiPaneInfo::IsValid(void)const " (?IsValid@wxAuiPaneInfo@@QBE_NXZ) referenced in function "public: class wxAuiPaneInfo & __thiscall wxAuiPaneInfo::DefaultPane(void)" (?DefaultPane@wxAuiPaneInfo@@QAEAAV1@XZ)
1>WxRoboCV_GUI.obj : error LNK2019: unresolved external symbol "public: class wxAuiPaneButtonArray & __thiscall wxAuiPaneButtonArray::operator=(class wxAuiPaneButtonArray const &)" (??4wxAuiPaneButtonArray@@QAEAAV0@ABV0@@Z) referenced in function "public: __thiscall wxAuiPaneInfo::wxAuiPaneInfo(class wxAuiPaneInfo const &)" (??0wxAuiPaneInfo@@QAE@ABV0@@Z)
1>WxRoboCV_GUI.obj : error LNK2019: unresolved external symbol "public: void __thiscall wxAuiManager::UnInit(void)" (?UnInit@wxAuiManager@@QAEXXZ) referenced in function "public: virtual __thiscall MainFrame_base::~MainFrame_base(void)" (??1MainFrame_base@@UAE@XZ)
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 »

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