JeVois
1.22
JeVois Smart Embedded Machine Vision Toolkit
|
|
#include <jevois/GPU/GPUimage.H>
Class to hold a GPUtexture, GPUprogram, and other data associated with rendering an image in OpenGL.
OpenGL should have been properly setup before this class is used.
Definition at line 38 of file GPUimage.H.
Public Member Functions | |
GPUimage () | |
Constructor. | |
~GPUimage () | |
Destructor. | |
void | set (RawImage const &img) |
Set pixel data from a vanilla RawImage, pixel data will be copied to texture. | |
void | set (cv::Mat const &img, bool rgb) |
Set pixel data from a vanilla OpenCV Mat, pixel data will be copied to texture. | |
void | set (InputFrame const &frame, EGLDisplay display) |
Set pixel data from camera input frame, sharing data with camera kernel driver using zero-copy. | |
void | set2 (InputFrame const &frame, EGLDisplay display) |
Set pixel data from camera input second (scaled) frame, sharing data with camera kernel driver using zero-copy. | |
void | draw (int &x, int &y, unsigned short &w, unsigned short &h, bool noalias, glm::mat4 const &pvm) |
Draw to OpenGL. | |
ImVec2 | i2d (ImVec2 const &p) |
Convert coordinates of a point from within a rendered image to on-screen. | |
ImVec2 | i2ds (ImVec2 const &p) |
Convert a 2D size from within a rendered image to on-screen. | |
ImVec2 | d2i (ImVec2 const &p) |
Convert coordinates of a point from on-screen to within a rendered image. | |
ImVec2 | d2is (ImVec2 const &p) |
Convert a 2D size from on-screen to within a rendered image. | |
void | twirl (float t, float alpha=1.0F) |
Optional twirl and alpha fading effect to the image, useful mostly for demos/transitions. | |
Protected Member Functions | |
void | setInternal (unsigned int width, unsigned int height, unsigned int fmt, unsigned char const *data) |
void | setWithDmaBuf (jevois::RawImage const &img, int dmafd, EGLDisplay display) |
Protected Attributes | |
EGLDisplay | itsDisplay |
std::shared_ptr< GPUtexture > | itsTexture |
std::shared_ptr< GPUprogram > | itsProgram |
std::shared_ptr< GPUtextureDmaBuf > | itsTextureDmaBuf |
GLuint | itsLocation = 0 |
GLuint | itsVertexArray = 0 |
GLuint | itsVertexBuffers [2] = { } |
int | itsDrawX = -1234567 |
int | itsDrawY = -6712345 |
unsigned int | itsDrawWidth = 0 |
unsigned int | itsDrawHeight = 0 |
unsigned int | itsTextureWidth = 0 |
unsigned int | itsTextureHeight = 0 |
unsigned int | itsFormat = 0 |
int | itsGLtextureWidth = 0 |
GLenum | itsGLtextureFmt = 0 |
GLfloat | itsTwirl = 0 |
GLfloat | itsAlpha = 0 |
jevois::GPUimage::GPUimage | ( | ) |
Constructor.
Definition at line 51 of file GPUimage.C.
jevois::GPUimage::~GPUimage | ( | ) |
Destructor.
Definition at line 55 of file GPUimage.C.
ImVec2 jevois::GPUimage::d2i | ( | ImVec2 const & | p | ) |
Convert coordinates of a point from on-screen to within a rendered image.
Throws if draw() has not been previously called.
Definition at line 420 of file GPUimage.C.
Referenced by jevois::GUIhelper::d2i().
ImVec2 jevois::GPUimage::d2is | ( | ImVec2 const & | p | ) |
Convert a 2D size from on-screen to within a rendered image.
Throws if draw() has not been previously called.
Definition at line 427 of file GPUimage.C.
Referenced by jevois::GUIhelper::d2is().
void jevois::GPUimage::draw | ( | int & | x, |
int & | y, | ||
unsigned short & | w, | ||
unsigned short & | h, | ||
bool | noalias, | ||
glm::mat4 const & | pvm | ||
) |
Draw to OpenGL.
If w=0 or h=0 then the image will be rescaled to fill the display as much as possible without changing the aspect ratio, and the actually used x,y,w,h will be returned. Otherwise, x,y,w,h are not modified. Throws if set() has not been previously called. If noalias is specified, the scaling factor will be rounded down to the nearest integer to prevent aliasing in the display. This may reduce the displayed image size. For example, with a 1920x1080 window, a 640x480 image would be letterboxed to 1440x1080 when noalias is false. But that is a scaling factor of 2.25 which may create rendering aliasing. When noalias is true, the letterboxed image size will be 1280x960 (scale factor of 2.0). The matrix pvm is the projection-view-model matrix to use for rendering.
Definition at line 282 of file GPUimage.C.
References jevois::applyLetterBox(), GL_CHECK, and h.
ImVec2 jevois::GPUimage::i2d | ( | ImVec2 const & | p | ) |
Convert coordinates of a point from within a rendered image to on-screen.
Throws if draw() has not been previously called.
Definition at line 406 of file GPUimage.C.
Referenced by jevois::GUIhelper::i2d().
ImVec2 jevois::GPUimage::i2ds | ( | ImVec2 const & | p | ) |
Convert a 2D size from within a rendered image to on-screen.
Throws if draw() has not been previously called.
Definition at line 413 of file GPUimage.C.
Referenced by jevois::GUIhelper::i2ds().
void jevois::GPUimage::set | ( | cv::Mat const & | img, |
bool | rgb | ||
) |
Set pixel data from a vanilla OpenCV Mat, pixel data will be copied to texture.
If image had three or four 8-bit channels, interpret as RGB[A] if rgb is true, otherwise BGR[A]. If two 8-bit channels, interpret at YUYV. If one, interpret at GRAY. The caller must guarantee that the pixel data will not be de-allocated until after draw() is called.
Definition at line 162 of file GPUimage.C.
References LFATAL.
void jevois::GPUimage::set | ( | jevois::InputFrame const & | frame, |
EGLDisplay | display | ||
) |
Set pixel data from camera input frame, sharing data with camera kernel driver using zero-copy.
The caller must guarantee that the pixel data will not be de-allocated (e.g., by calling done() on the InputFrame) until after draw() is called. Zero-copy requires DMABUF sharing between V4L2 and OpenGL-ES and is only available on JeVois-Pro platform. On other hardware configs, this falls back to set(RawImage) using the RawImage from the InputFrame.
Definition at line 180 of file GPUimage.C.
References jevois::RawImage::buf, jevois::RawImage::fmt, jevois::InputFrame::get(), and jevois::RawImage::width.
void jevois::GPUimage::set | ( | jevois::RawImage const & | img | ) |
Set pixel data from a vanilla RawImage, pixel data will be copied to texture.
The caller must guarantee that the pixel data will not be de-allocated until after draw() is called.
Definition at line 156 of file GPUimage.C.
References jevois::RawImage::buf, jevois::RawImage::fmt, jevois::RawImage::height, and jevois::RawImage::width.
void jevois::GPUimage::set2 | ( | jevois::InputFrame const & | frame, |
EGLDisplay | display | ||
) |
Set pixel data from camera input second (scaled) frame, sharing data with camera kernel driver using zero-copy.
The caller must guarantee that the pixel data will not be de-allocated (e.g., by calling done() on the InputFrame) until after draw() is called. Zero-copy requires DMABUF sharing between V4L2 and OpenGL-ES and is only available on JeVois-Pro platform. On other hardware configs, this falls back to set(RawImage) using the RawImage from the InputFrame. Throws unless we are JeVois-Pro Platform and the camera is set to CropScale mode.
Definition at line 206 of file GPUimage.C.
References jevois::RawImage::buf, jevois::RawImage::fmt, jevois::InputFrame::get2(), and jevois::RawImage::width.
|
protected |
Definition at line 62 of file GPUimage.C.
References jevois::fccstr(), jevois::shader::frag_grey, jevois::shader::frag_grey_twirl, jevois::shader::frag_rgb, jevois::shader::frag_rgb_twirl, jevois::shader::frag_rgba, jevois::shader::frag_rgba_twirl, jevois::shader::frag_yuyv, jevois::shader::frag_yuyv_twirl, LDEBUG, LFATAL, and jevois::shader::vert.
|
protected |
Definition at line 232 of file GPUimage.C.
References jevois::fccstr(), jevois::RawImage::fmt, jevois::shader::frag_oes, jevois::shader::frag_oes_twirl, jevois::RawImage::height, LDEBUG, LFATAL, jevois::shader::vert, and jevois::RawImage::width.
void jevois::GPUimage::twirl | ( | float | t, |
float | alpha = 1.0F |
||
) |
Optional twirl and alpha fading effect to the image, useful mostly for demos/transitions.
Definition at line 434 of file GPUimage.C.
|
protected |
Definition at line 123 of file GPUimage.H.
|
protected |
Definition at line 105 of file GPUimage.H.
|
protected |
Definition at line 117 of file GPUimage.H.
|
protected |
Definition at line 117 of file GPUimage.H.
|
protected |
Definition at line 116 of file GPUimage.H.
|
protected |
Definition at line 116 of file GPUimage.H.
|
protected |
Definition at line 119 of file GPUimage.H.
|
protected |
Definition at line 121 of file GPUimage.H.
|
protected |
Definition at line 120 of file GPUimage.H.
|
protected |
Definition at line 112 of file GPUimage.H.
|
protected |
Definition at line 107 of file GPUimage.H.
|
protected |
Definition at line 106 of file GPUimage.H.
|
protected |
Definition at line 110 of file GPUimage.H.
|
protected |
Definition at line 118 of file GPUimage.H.
|
protected |
Definition at line 118 of file GPUimage.H.
|
protected |
Definition at line 122 of file GPUimage.H.
|
protected |
Definition at line 113 of file GPUimage.H.
|
protected |
Definition at line 114 of file GPUimage.H.