Showing images from a video stream

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
NonoNano
Experienced Solver
Experienced Solver
Posts: 71
Joined: Sun Mar 25, 2018 6:12 pm

Showing images from a video stream

Post by NonoNano » Sun Mar 25, 2018 6:54 pm

Hello,

I'm developing an application based on wxWidgets that must connect to a camera, start acquiring images and show these images on some graphical object capable to visualize bitmap pictures. While the tasks of connecting and capturing the images are performed by the camera libraries I still don't know which is the correct graphical object that I should use to show each grabbed image (that means showing the real-time video). Can anyone tell me which is the best way to achieve this? Is there any example that I could start with? Thank you!

User avatar
doublemax
Moderator
Moderator
Posts: 15283
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Showing images from a video stream

Post by doublemax » Sun Mar 25, 2018 7:11 pm

I have some old sample code from an experiment with OpenCV.

mainFrame::OnTimer() is a timer event handler that gets the image and copies the raw RGB data into a bitmap.
mainFrame::OnPaint() draws the bitmap on screen.

It's very barebone but should contain everything you need.
Attachments
mainframe.h
(570 Bytes) Downloaded 177 times
mainframe.cpp
(2.78 KiB) Downloaded 220 times
Use the source, Luke!

User avatar
eranon
Can't get richer than this
Can't get richer than this
Posts: 867
Joined: Sun May 13, 2012 11:42 pm
Location: France
Contact:

Re: Showing images from a video stream

Post by eranon » Mon Mar 26, 2018 10:55 am

Hello, It also depends on the lib or API you're using to communicate with the video device. Does it provides a prototype for a callback function you have to implement? If yes, it's the place to acquire each frame... Then, you display it during a paint event handler as doublemax showed you.
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]

NonoNano
Experienced Solver
Experienced Solver
Posts: 71
Joined: Sun Mar 25, 2018 6:12 pm

Re: Showing images from a video stream

Post by NonoNano » Mon Mar 26, 2018 3:08 pm

Hello,

thank you very much for your help. I'm trying to integrate the example posted by DoubleMax with my project but I have some difficoulties.
In the constructor of my main form I'm trying to register the "OnPaint" event like this:

Code: Select all

Connect(wxID_ANY, wxEVT_PAINT, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) &CameraGUIForm::OnPaint);
since using the event table is giving me errors at compile time. Then inside a button where I put the grabbing cycle (only for trial purposes, it will be moved on a thread as soon as I get something working) I call 'this->Refresh();'. The OnPaint method is called only once right after the constructor finishes its job. It is never called afterwards, while the grabbing cycle is running. Its seems that the code is capturing correctely the images but not showing them. You can find my code attached.
I have also another quesiton:
In 'OnTimer' function where it is written:

Code: Select all

imgdata += img->widthStep;
since my pixel data is expressed as a 8 bit data should I replace it with:

Code: Select all

imgdata += 8;
?

Thanks!
Attachments
CameraGUIForm.h
(862 Bytes) Downloaded 82 times
CameraGUIForm.cpp
(6.29 KiB) Downloaded 84 times

User avatar
doublemax
Moderator
Moderator
Posts: 15283
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Showing images from a video stream

Post by doublemax » Mon Mar 26, 2018 3:31 pm

The OnPaint method is called only once right after the constructor finishes its job. It is never called afterwards, while the grabbing cycle is running. Its seems that the code is capturing correctely the images but not showing them.
With the "while ( USBcamera1->IsGrabbing())" you're creating a tight loop during which no events will be processed. This is a really bad way of doing things, just for testing purposes add a ::wxYield(); after the Refresh(). This will call the event dispatcher and the paint event handler should be called. But this should not remain in the final app.
since my pixel data is expressed as a 8 bit data should I replace it with:

Code: Select all

Select all
imgdata += 8;
No. img->widthStep is the distance in bytes from the beginning of one line of pixels to the next. If your data is 24Bit RGB, you should write

Code: Select all

imgdata += w*3;
Use the source, Luke!

NonoNano
Experienced Solver
Experienced Solver
Posts: 71
Joined: Sun Mar 25, 2018 6:12 pm

Re: Showing images from a video stream

Post by NonoNano » Tue Mar 27, 2018 6:54 am

Hello,

unfortunately the "OnPaint" function it is still not called, even if I put "::wxYield();" right after te "Refresh()". Maybe there is something wrong in the way I'm binding the PAINT event..but it would be strange since the event is called once at the beginning. Could it be that the "Refresh()" function called inside a button is refreshing only the button? I will try to search again in the web..any suggestion is very appreciated!
Thank you!

User avatar
eranon
Can't get richer than this
Can't get richer than this
Posts: 867
Joined: Sun May 13, 2012 11:42 pm
Location: France
Contact:

Re: Showing images from a video stream

Post by eranon » Tue Mar 27, 2018 7:18 am

Hello, Is your OnPaint function called at a time or another (I mean, outside of the moment you force a refresh)? If it's never called, then there is effectively a link problem with your Connect (so, you could maybe try a static event table as shown below). If yes (it's called somewhere), the issue is local and specific to your code to call it explicitly (the way you refresh).

Code: Select all

wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
    EVT_PAINT(MyFrame::OnPaint)
wxEND_EVENT_TABLE()
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]

NonoNano
Experienced Solver
Experienced Solver
Posts: 71
Joined: Sun Mar 25, 2018 6:12 pm

Re: Showing images from a video stream

Post by NonoNano » Tue Mar 27, 2018 7:41 am

Thank you for your reply. I never call explicitly the function OnPaint.
Unfortunately if I try to use an event table I get these errors at compile time:

||=== Build: Debug in CameraGUI (compiler: GNU GCC Compiler) ===|
/opt/pylon5/include/GenApi/IBase.h|39|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IBase.h|40|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IBase.h|109|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/Container.h|56|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/INode.h|43|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/INode.h|44|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/INode.h|317|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IValue.h|41|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IValue.h|42|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IValue.h|147|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IEnumEntry.h|38|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IEnumEntry.h|39|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IEnumEntry.h|136|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IEnumeration.h|40|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IEnumeration.h|41|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IEnumeration.h|97|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IFloat.h|38|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IFloat.h|39|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IFloat.h|317|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IInteger.h|38|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IInteger.h|39|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IInteger.h|278|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/Pointer.h|265|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/Pointer.h|266|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/Pointer.h|268|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/ICategory.h|43|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/ICategory.h|44|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/ICategory.h|109|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IRegister.h|38|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IRegister.h|39|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IRegister.h|145|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IBoolean.h|38|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IBoolean.h|39|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IBoolean.h|148|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IPort.h|39|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IPort.h|40|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IPort.h|110|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IPortRecorder.h|36|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IPortRecorder.h|37|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IPortRecorder.h|145|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IChunkPort.h|39|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IChunkPort.h|40|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IChunkPort.h|74|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IString.h|39|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IString.h|40|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IString.h|167|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/INodeMap.h|40|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/INodeMap.h|41|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/INodeMap.h|87|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IDestroy.h|18|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IDestroy.h|19|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IDestroy.h|41|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IDeviceInfo.h|36|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IDeviceInfo.h|37|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IDeviceInfo.h|81|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/ISelector.h|35|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/ISelector.h|36|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/ISelector.h|109|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/ICommand.h|38|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/ICommand.h|39|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/ICommand.h|132|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IUserData.h|17|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IUserData.h|18|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/IUserData.h|42|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/PortImpl.h|41|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/PortImpl.h|42|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/PortImpl.h|43|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/PortImpl.h|47|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/PortImpl.h|48|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/PortImpl.h|49|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/PortImpl.h|140|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/opt/pylon5/include/GenApi/PortImpl.h|143|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/usr/include/wx-3.0/wx/event.h|3998|error: ISO C++ does not permit ‘wxFrameBase::sm_eventTable’ to be defined as ‘CameraGUIForm::sm_eventTable’ [-fpermissive]|
/home/pi/Desktop/Prova/CameraGUI/CameraGUIForm.cpp|9|note: in expansion of macro ‘wxBEGIN_EVENT_TABLE’|
/usr/include/wx-3.0/wx/event.h|3986|error: ‘const wxEventTableEntry wxFrameBase::sm_eventTableEntries []’ is private|
/usr/include/wx-3.0/wx/event.h|4451|note: in expansion of macro ‘wxDECLARE_EVENT_TABLE’|
/usr/include/wx-3.0/wx/frame.h|247|note: in expansion of macro ‘DECLARE_EVENT_TABLE’|
/usr/include/wx-3.0/wx/event.h|3999|error: within this context|
/home/pi/Desktop/Prova/CameraGUI/CameraGUIForm.cpp|9|note: in expansion of macro ‘wxBEGIN_EVENT_TABLE’|
/usr/include/wx-3.0/wx/event.h|4000|error: no ‘const wxEventTable* CameraGUIForm::GetEventTable() const’ member function declared in class ‘CameraGUIForm’|
/home/pi/Desktop/Prova/CameraGUI/CameraGUIForm.cpp|9|note: in expansion of macro ‘wxBEGIN_EVENT_TABLE’|
/usr/include/wx-3.0/wx/event.h|4002|error: ISO C++ does not permit ‘wxFrameBase::sm_eventHashTable’ to be defined as ‘CameraGUIForm::sm_eventHashTable’ [-fpermissive]|
/home/pi/Desktop/Prova/CameraGUI/CameraGUIForm.cpp|9|note: in expansion of macro ‘wxBEGIN_EVENT_TABLE’|
/usr/include/wx-3.0/wx/event.h|4003|error: no ‘wxEventHashTable& CameraGUIForm::GetEventHashTable() const’ member function declared in class ‘CameraGUIForm’|
/home/pi/Desktop/Prova/CameraGUI/CameraGUIForm.cpp|9|note: in expansion of macro ‘wxBEGIN_EVENT_TABLE’|
/usr/include/wx-3.0/wx/event.h|4005|error: ISO C++ does not permit ‘wxFrameBase::sm_eventTableEntries’ to be defined as ‘CameraGUIForm::sm_eventTableEntries’ [-fpermissive]|
/home/pi/Desktop/Prova/CameraGUI/CameraGUIForm.cpp|9|note: in expansion of macro ‘wxBEGIN_EVENT_TABLE’|
/home/pi/Desktop/Prova/CameraGUI/CameraGUIForm.cpp||In constructor ‘CameraGUIForm::CameraGUIForm()’:|
/home/pi/Desktop/Prova/CameraGUI/CameraGUIForm.cpp|55|warning: unused variable ‘button2’ [-Wunused-variable]|
||=== Build failed: 7 error(s), 73 warning(s) (0 minute(s), 21 second(s)) ===|

User avatar
eranon
Can't get richer than this
Can't get richer than this
Posts: 867
Joined: Sun May 13, 2012 11:42 pm
Location: France
Contact:

Re: Showing images from a video stream

Post by eranon » Tue Mar 27, 2018 7:53 am

NonoNano wrote:Thank you for your reply. I never call explicitly the function OnPaint.
I didn't say you directly called OnPaint (nobody calls an event handler directly), but you explicitely induce an indirect call to the WM_PAINT event handler by your Refresh(), then wxYield() to immediately proceed with the queue. So, the question was : does this handler reached outside of this Refresh call? You just have to put a breakpoint in your OnPaint function and see if it's called when you launch your app; nothing more.

About your error, it sounds like this thread: viewtopic.php?t=16861
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]

User avatar
doublemax
Moderator
Moderator
Posts: 15283
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Showing images from a video stream

Post by doublemax » Tue Mar 27, 2018 8:09 am

How do you know that the paint event handler is never called? In that case you would never see the bitmap.

In order to use a static event table, you need to add the wxDECLARE_EVENT_TABLE macro:

Code: Select all

class CameraGUIForm : public wxFrame
{
public:
    Camera_t* USBcamera1;
    CameraGUIForm();
    void OnQuit(wxCommandEvent & event);
    void OnButton2(wxCommandEvent & event);
    void OnPaint(wxPaintEvent& event);
    void toWXBitmap(unsigned char * imgdata, int w, int h);


private:
    wxBitmap *m_bitmap;
    wxFrame *main_frame;

    wxDECLARE_EVENT_TABLE();
};
Also, try to replace

Code: Select all

Connect(wxID_ANY, wxEVT_PAINT, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) &CameraGUIForm::OnPaint);
with:

Code: Select all

Connect(wxID_ANY, wxEVT_PAINT, (wxPaintEventHandler) &CameraGUIForm::OnPaint);
BTW: wxWidgets itself never throws exceptions, so the try/catch in toWXBitmap are not needed.
Use the source, Luke!

NonoNano
Experienced Solver
Experienced Solver
Posts: 71
Joined: Sun Mar 25, 2018 6:12 pm

Re: Showing images from a video stream

Post by NonoNano » Tue Mar 27, 2018 9:43 am

eranon wrote:So, the question was : does this handler reached outside of this Refresh call? You just have to put a breakpoint in your OnPaint function and see if it's called when you launch your app; nothing more.
The OnPaint is actually called but it is called only once, right after the constructor of my form finishes to execute (namely when I launch my app).

@doublemax: thanks to your suggestion now I can use the event table insetead of the Connection function. Unfortunately the behaviour is the same as before: OnPaint is called only once at the beginning and never called again..it seems that Refresh() called inside the button is not forcing the refresh of the entire form. Is that dued to the fact that Refresh() is called inside the event of the button? At some point I will move the grabbing actions inside an event generated by the camera libraries. This event is issued every time the camera has finished grabbing an image. Could this modification solve also this problem?

User avatar
doublemax
Moderator
Moderator
Posts: 15283
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Showing images from a video stream

Post by doublemax » Tue Mar 27, 2018 10:34 am

OnPaint is called only once at the beginning and never called again.
One more thing you can try is to call Update() right after Refresh().
At some point I will move the grabbing actions inside an event generated by the camera libraries. This event is issued every time the camera has finished grabbing an image. Could this modification solve also this problem?
This is definitely a better solution.
Use the source, Luke!

NonoNano
Experienced Solver
Experienced Solver
Posts: 71
Joined: Sun Mar 25, 2018 6:12 pm

Re: Showing images from a video stream

Post by NonoNano » Wed Mar 28, 2018 1:02 pm

Hello,

I managed to change my code like this: whereas before I had a while loop inside a button that was in charge of retrive the grab results (blocking the GUI execution) now I am exploiting an event triggered by the camera libraries each time a picture is captured. This is way better than before in principle but now I'm facing problems that I expected: how do I access to the GUI objects from this event?
In particular this is my event:

Code: Select all

public:
    virtual void OnImageGrabbed(CInstantCamera& camera, const CGrabResultPtr& ptrGrabResult)
    {
        cout << "Grabbed image";

        if (ptrGrabResult && ptrGrabResult->GrabSucceeded())
            {
                // Access the image data.
                cout << "SizeX: " << ptrGrabResult->GetWidth() << endl;
                cout << "SizeY: " << ptrGrabResult->GetHeight() << endl;
                unsigned char *pImageBuffer = (unsigned char *) ptrGrabResult->GetBuffer();
                int width = (int) ptrGrabResult->GetWidth();
                int height = (int) ptrGrabResult->GetHeight();
                //toWXBitmap(pImageBuffer, width, height);

                //this->Refresh();
                //this->Update();
            }
            else
            {
                cout << "Error: " << ptrGrabResult->GetErrorCode() << " " << ptrGrabResult->GetErrorDescription() << endl;
            }
    }
};
first problem: 'toWXBitmap' is the function that converts my char buffer in a wxBitmap object. If I try to call inside my function it gives me errors at compile time:
/home/pi/Desktop/Prova/CameraGUI/CameraGUIForm.cpp|34|error: too many arguments to function ‘void toWXBitmap(const unsigned char*)’|
but my function has a different signature and takes in input three parameters (that is the way I'm calling it). If I call that function elsewhere (e.g. inside the button event) I get no errors. Moreover inside 'toWXBitmap' I refer to a field called 'wxBitmap *m_bitmap;' that I don't think it is visible at that scope (when I'm inside that event I cannot refer to fields of the GUI object).
Secondly I cannot call 'this->Refresh();' inside that event.
Any ideas on how to solve those issues? If someone is interested you can find my code attached. Thank you!
Attachments
CameraGUIForm.h
(927 Bytes) Downloaded 51 times
CameraGUIForm.cpp
(9.08 KiB) Downloaded 62 times

User avatar
doublemax
Moderator
Moderator
Posts: 15283
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Showing images from a video stream

Post by doublemax » Wed Mar 28, 2018 2:12 pm

Code: Select all

/home/pi/Desktop/Prova/CameraGUI/CameraGUIForm.cpp|34|error: too many arguments to function ‘void toWXBitmap(const unsigned char*)’|
There is a wrong (old) signature near the top of the source file:

Code: Select all

void toWXBitmap(const unsigned char * buffer);
Moreover inside 'toWXBitmap' I refer to a field called 'wxBitmap *m_bitmap;' that I don't think it is visible at that scope (when I'm inside that event I cannot refer to fields of the GUI object).
Secondly I cannot call 'this->Refresh();' inside that event.
Modify the CCameraImageEventHandler so that it takes a CameraGUIForm* (or whatever suits your purpose) and save it in a member variable. Then you can access from inside the event handler.
Use the source, Luke!

NonoNano
Experienced Solver
Experienced Solver
Posts: 71
Joined: Sun Mar 25, 2018 6:12 pm

Re: Showing images from a video stream

Post by NonoNano » Wed Mar 28, 2018 3:44 pm

Hello,

thank you for your reply! Are you sure that it is correct? They say not to access GUI objects of the main thread from a secondary one

Post Reply