Showing images from a video stream
Re: Showing images from a video stream
I'm pretty sure it's possible to speed this up, but we need a Linux/GTK expert for this
Googling a bit i found:
https://developer.gnome.org/gdk-pixbuf/ ... -from-data
GdkPixbuf is the internal representation of a bitmap under GTK.
And in wxGTK there is a constructor for wxBitmap that takes a GdkPixbuf as parameter:
wxBitmap::wxBitmap(GdkPixbuf* pixbuf, int depth)
Try experimenting with this.
Googling a bit i found:
https://developer.gnome.org/gdk-pixbuf/ ... -from-data
GdkPixbuf is the internal representation of a bitmap under GTK.
And in wxGTK there is a constructor for wxBitmap that takes a GdkPixbuf as parameter:
wxBitmap::wxBitmap(GdkPixbuf* pixbuf, int depth)
Try experimenting with this.
Use the source, Luke!
Re: Showing images from a video stream
Unfortunately I'm new to linux programming/c++, find out a path starting from that is too complex for me..if I don't find an easier way to achieve the result I must give up. Of course, if someone has suggestions I will always be happy to try them!
EDIT: desperate trial,
cannot work?
EDIT2: ok I answered myself: it works only for monochromatic images
EDIT: desperate trial,
Code: Select all
m_bitmap = new wxBitmap((const char *)copyImageBuffer,640, 480, 3);
EDIT2: ok I answered myself: it works only for monochromatic images
Re: Showing images from a video stream
Can you try to build and run one of the OpenGL samples that come with wxWidgets?
E.g. <wxdir>/samples/opengl/cube/
E.g. <wxdir>/samples/opengl/cube/
Use the source, Luke!
Re: Showing images from a video stream
Hello! Unfortunately I have not examples installed..thats all I have:
Never mind..I would like to thank you again for your priceless help!/usr/lib/arm-linux-gnueabihf/wx
/usr/lib/arm-linux-gnueabihf/wx/include
/usr/lib/arm-linux-gnueabihf/wx/include/gtk2-unicode-3.0
/usr/lib/arm-linux-gnueabihf/wx/include/gtk2-unicode-3.0/wx
/usr/lib/arm-linux-gnueabihf/wx/include/gtk2-unicode-3.0/wx/setup.h
/usr/lib/arm-linux-gnueabihf/wx/config
/usr/lib/arm-linux-gnueabihf/wx/config/gtk2-unicode-3.0
/usr/share
/usr/share/doc
/usr/share/doc/libwxgtk3.0-dev
/usr/share/doc/libwxgtk3.0-dev/copyright
/usr/share/doc/libwxgtk3.0-dev/changelog.Debian.gz
/usr/share/doc/libwxgtk3.0-dev/changelog.gz
/usr/lib/arm-linux-gnueabihf/libwx_gtk2u_xrc-3.0.so
/usr/lib/arm-linux-gnueabihf/libwx_gtk2u_stc-3.0.so
/usr/lib/arm-linux-gnueabihf/libwx_gtk2u_richtext-3.0.so
/usr/lib/arm-linux-gnueabihf/libwx_gtk2u_ribbon-3.0.so
/usr/lib/arm-linux-gnueabihf/libwx_gtk2u_qa-3.0.so
/usr/lib/arm-linux-gnueabihf/libwx_gtk2u_propgrid-3.0.so
/usr/lib/arm-linux-gnueabihf/libwx_gtk2u_html-3.0.so
/usr/lib/arm-linux-gnueabihf/libwx_gtk2u_gl-3.0.so
/usr/lib/arm-linux-gnueabihf/libwx_gtk2u_core-3.0.so
/usr/lib/arm-linux-gnueabihf/libwx_gtk2u_aui-3.0.so
/usr/lib/arm-linux-gnueabihf/libwx_gtk2u_adv-3.0.so
Re: Showing images from a video stream
Don't give up yet
Based on the OpenGL samples and some code in found on Google, i hacked something together. I'm really interested if this is fast(er).
You need at add at least libwx_gtk2u_gl-3.0.so to the libraries. If you have problems with this, please open a new thread in Compiler/Linker/IDE related, hopefully David can help with this.
I only adjusted CameraGUIForm.cpp to work with the new class and removed some (now) unneeded code, but not the the header file. And of course these changes were all made "blindly" as i couldn't even try to compile this because of all the Pylon stuff. So you have to make some more changes yourself.
This should be faster than the old code. On my PC i'm getting about 1300fps with a 640x480 image.
Based on the OpenGL samples and some code in found on Google, i hacked something together. I'm really interested if this is fast(er).
You need at add at least libwx_gtk2u_gl-3.0.so to the libraries. If you have problems with this, please open a new thread in Compiler/Linker/IDE related, hopefully David can help with this.
I only adjusted CameraGUIForm.cpp to work with the new class and removed some (now) unneeded code, but not the the header file. And of course these changes were all made "blindly" as i couldn't even try to compile this because of all the Pylon stuff. So you have to make some more changes yourself.
This should be faster than the old code. On my PC i'm getting about 1300fps with a 640x480 image.
- Attachments
-
- CameraGUIForm.cpp
- (6.05 KiB) Downloaded 217 times
-
- gl_bitmap_panel.h
- (2.94 KiB) Downloaded 198 times
Use the source, Luke!
Re: Showing images from a video stream
Thank you very much!
I'm trying to integrate your code but I get this error:
I'm trying to integrate your code but I get this error:
dued to this part of code:/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|77|error: no matching function for call to ‘GLBitmapPanel::CallAfter(GLBitmapPanel::SetBitmapData(const unsigned char*, GLBitmapPanel::PixelFormat, int, int, int)::<lambda()>)’|
it seems to me to have included all the libraries..maybe I have some old version?CallAfter( [this] {
Refresh();
});
Re: Showing images from a video stream
I don't know why the compiler doesn't like this. Comment that part out and replace it with a single call to Refresh().
Use the source, Luke!
Re: Showing images from a video stream
I really cannot understand why but now I'm getting errors in the pylon libraries:
in here/opt/pylon5/include/GenApi/Types.h|130|error: expected identifier before numeric constant|
/opt/pylon5/include/GenApi/Types.h|130|error: expected ‘}’ before numeric constant|
/opt/pylon5/include/GenApi/Types.h|130|error: expected unqualified-id before numeric constant|
/opt/pylon5/include/GenApi/Types.h|136|error: ‘EStandardNameSpace’ does not name a type|
/opt/pylon5/include/GenApi/Types.h|245|error: expected declaration before ‘}’ token|
||=== Build failed: 5 error(s), 72 warning(s) (0 minute(s), 10 second(s)) ===|
typedef enum _EStandardNameSpace
{
None, //!< name resides in custom namespace
GEV, //!< name resides in GigE Vision namespace
IIDC, //!< name resides in 1394 IIDC namespace
CL, //!< name resides in camera link namespace
USB, //!< name resides in USB namespace
_UndefinedStandardNameSpace //!< Object is not yet initialized
} EStandardNameSpace;
Re: Showing images from a video stream
I guess you added #include "gl_bitmap_panel.h" to the header file? Try not to do that and just use a forward reference to GLBitmapPanel for the member variable you need in CameraGUIForm.
Use the source, Luke!
Re: Showing images from a video stream
Yeah you are right..I did that! What do yo mean by:
?use a forward reference to GLBitmapPanel for the member variable you need in CameraGUIForm.
Re: Showing images from a video stream
Instead of:
Use:
As you only have a pointer to GLBitmapPanel in the CameraGUIForm, the compiler doesn't need to know everything about that class at this stage. It only needs to know that it exists.
Code: Select all
#include "gl_bitmap_panel.h"
class CameraGUIForm : public wxFrame
{
public:
Camera_t* USBcamera1;
wxStaticText* label;
wxStaticText* label1;
GLBitmapPanel *m_bitmap_panel;
int counter;
CameraGUIForm();
void OnQuit(wxCommandEvent & event);
void OnButton2(wxCommandEvent & event);
void OnButton3(wxCommandEvent & event);
void OnPaint(wxPaintEvent& event);
void OnGrabbed(wxCommandEvent& event);
void toWXBitmap(unsigned char * imgdata, int w, int h);
void grab();
unsigned char *previousImageBuffer;
private:
wxFrame *main_frame;
wxDECLARE_EVENT_TABLE();
};
Code: Select all
class GLBitmapPanel; // <- so called "forward reference"
class CameraGUIForm : public wxFrame
{
public:
Camera_t* USBcamera1;
wxStaticText* label;
wxStaticText* label1;
GLBitmapPanel *m_bitmap_panel;
int counter;
CameraGUIForm();
void OnQuit(wxCommandEvent & event);
void OnButton2(wxCommandEvent & event);
void OnButton3(wxCommandEvent & event);
void OnPaint(wxPaintEvent& event);
void OnGrabbed(wxCommandEvent& event);
void toWXBitmap(unsigned char * imgdata, int w, int h);
void grab();
unsigned char *previousImageBuffer;
private:
wxFrame *main_frame;
wxDECLARE_EVENT_TABLE();
};
Use the source, Luke!
Re: Showing images from a video stream
Yes that works!
But after that still compiling errors:
But after that still compiling errors:
Do I miss some reference?obj/Debug/CameraGUIForm.o||In function `wxGLCanvas::~wxGLCanvas()':|
/usr/include/wx-3.0/wx/gtk/glcanvas.h|20|undefined reference to `wxGLCanvasX11::~wxGLCanvasX11()'|
/usr/include/wx-3.0/wx/gtk/glcanvas.h|20|undefined reference to `vtable for wxGLCanvas'|
obj/Debug/CameraGUIForm.o||In function `GLBitmapPanel::GLBitmapPanel(wxWindow*, int, wxPoint const&, wxSize const&)':|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|15|undefined reference to `wxGLCanvas::wxGLCanvas(wxWindow*, int, int const*, wxPoint const&, wxSize const&, long, wxString const&, wxPalette const&)'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|21|undefined reference to `wxGLContext::wxGLContext(wxGLCanvas*, wxGLContext const*)'|
obj/Debug/CameraGUIForm.o||In function `GLBitmapPanel::Render()':|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|39|undefined reference to `glPixelZoom'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|40|undefined reference to `glRasterPos2i'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|41|undefined reference to `glDrawPixels'|
obj/Debug/CameraGUIForm.o||In function `GLBitmapPanel::SetupGL()':|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|94|undefined reference to `glEnable'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|95|undefined reference to `glDepthMask'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|96|undefined reference to `glDisable'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|98|undefined reference to `glMatrixMode'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|99|undefined reference to `glLoadIdentity'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|101|undefined reference to `glOrtho'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|102|undefined reference to `glViewport'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|104|undefined reference to `glMatrixMode'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|105|undefined reference to `glLoadIdentity'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|107|undefined reference to `glEnable'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|108|undefined reference to `glBlendFunc'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|111|undefined reference to `glClearColor'|
/home/pi/Desktop/Prova/CameraGUI_OpenGL/gl_bitmap_panel.h|112|undefined reference to `glClear'|
obj/Debug/CameraGUIForm.o:(.rodata._ZTV13GLBitmapPanel[_ZTV13GLBitmapPanel]+0x8)||undefined reference to `wxGLCanvas::GetClassInfo() const'|
obj/Debug/CameraGUIForm.o:(.rodata._ZTV13GLBitmapPanel[_ZTV13GLBitmapPanel]+0xfc)||undefined reference to `wxGLCanvasX11::IsShownOnScreen() const'|
obj/Debug/CameraGUIForm.o:(.rodata._ZTV13GLBitmapPanel[_ZTV13GLBitmapPanel]+0x19c)||undefined reference to `wxGLCanvas::SetBackgroundStyle(wxBackgroundStyle)'|
obj/Debug/CameraGUIForm.o:(.rodata._ZTV13GLBitmapPanel[_ZTV13GLBitmapPanel]+0x230)||undefined reference to `wxGLCanvas::OnInternalIdle()'|
obj/Debug/CameraGUIForm.o:(.rodata._ZTV13GLBitmapPanel[_ZTV13GLBitmapPanel]+0x310)||undefined reference to `wxGLCanvasX11::SwapBuffers()'|
obj/Debug/CameraGUIForm.o:(.rodata._ZTV13GLBitmapPanel[_ZTV13GLBitmapPanel]+0x31c)||undefined reference to `wxGLCanvas::GetXWindow() const'|
obj/Debug/CameraGUIForm.o:(.rodata._ZTI13GLBitmapPanel[_ZTI13GLBitmapPanel]+0x8)||undefined reference to `typeinfo for wxGLCanvas'|
||=== Build failed: 27 error(s), 152 warning(s) (1 minute(s), 10 second(s)) ===|
Re: Showing images from a video stream
It seems that "just" the OpenGL libs are missing. Unfortunately that's the part where i can't help for Linux. Try opening a new thread in Compiler/Linker/IDE related.
Use the source, Luke!
Re: Showing images from a video stream
Ok thank you very much! I will do it!
Re: Showing images from a video stream
I'm still testing the solution without openGL..besides the fact it is occupying a lot of CPU the strange thing is that it starts fine (reactivity of the camera is good) and after some minutes is going worse and worse until it seems that it is going 3fps.