JeVois  1.16
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
jevois::GPUimage Class Reference

#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.

Collaboration diagram for jevois::GPUimage:

Public Member Functions

 GPUimage ()
 Constructor. More...
 
 ~GPUimage ()
 Destructor. More...
 
void set (RawImage const &img)
 Set pixel data from a vanilla RawImage, pixel data will be copied to texture. More...
 
void set (cv::Mat const &img, bool rgb)
 Set pixel data from a vanilla OpenCV Mat, pixel data will be copied to texture. More...
 
void set (InputFrame const &frame, EGLDisplay display)
 Set pixel data from camera input frame, sharing data with camera kernel driver using zero-copy. More...
 
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. More...
 
void draw (int &x, int &y, unsigned short &w, unsigned short &h, bool noalias, glm::mat4 const &pvm)
 Draw to OpenGL. More...
 
ImVec2 i2d (ImVec2 const &p)
 Convert coordinates of a point from within a rendered image to on-screen. More...
 
ImVec2 i2ds (ImVec2 const &p)
 Convert a 2D size from within a rendered image to on-screen. More...
 

Protected Member Functions

void setInternal (unsigned int width, unsigned int height, unsigned int fmt, unsigned char const *data)
 

Protected Attributes

EGLDisplay itsDisplay
 
std::shared_ptr< GPUtextureitsTexture
 
std::shared_ptr< GPUprogramitsProgram
 
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
 

Constructor & Destructor Documentation

◆ GPUimage()

jevois::GPUimage::GPUimage ( )

Constructor.

Definition at line 45 of file GPUimage.C.

◆ ~GPUimage()

jevois::GPUimage::~GPUimage ( )

Destructor.

Definition at line 49 of file GPUimage.C.

Member Function Documentation

◆ draw()

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 257 of file GPUimage.C.

References jevois::applyLetterBox(), GL_CHECK, and h.

◆ i2d()

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 375 of file GPUimage.C.

Referenced by jevois::GUIhelper::i2d().

◆ i2ds()

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 382 of file GPUimage.C.

Referenced by jevois::GUIhelper::i2ds().

◆ set() [1/3]

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 136 of file GPUimage.C.

References LFATAL.

◆ set() [2/3]

void jevois::GPUimage::set ( 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.

◆ set() [3/3]

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 130 of file GPUimage.C.

References jevois::RawImage::buf, jevois::RawImage::fmt, jevois::RawImage::height, and jevois::RawImage::width.

◆ set2()

void jevois::GPUimage::set2 ( 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 247 of file GPUimage.C.

References jevois::InputFrame::get2().

◆ setInternal()

void jevois::GPUimage::setInternal ( unsigned int  width,
unsigned int  height,
unsigned int  fmt,
unsigned char const *  data 
)
protected

Member Data Documentation

◆ itsDisplay

EGLDisplay jevois::GPUimage::itsDisplay
protected

Definition at line 94 of file GPUimage.H.

◆ itsDrawHeight

unsigned int jevois::GPUimage::itsDrawHeight = 0
protected

Definition at line 106 of file GPUimage.H.

◆ itsDrawWidth

unsigned int jevois::GPUimage::itsDrawWidth = 0
protected

Definition at line 106 of file GPUimage.H.

◆ itsDrawX

int jevois::GPUimage::itsDrawX = -1234567
protected

Definition at line 105 of file GPUimage.H.

◆ itsDrawY

int jevois::GPUimage::itsDrawY = -6712345
protected

Definition at line 105 of file GPUimage.H.

◆ itsFormat

unsigned int jevois::GPUimage::itsFormat = 0
protected

Definition at line 108 of file GPUimage.H.

◆ itsGLtextureFmt

GLenum jevois::GPUimage::itsGLtextureFmt = 0
protected

Definition at line 110 of file GPUimage.H.

◆ itsGLtextureWidth

int jevois::GPUimage::itsGLtextureWidth = 0
protected

Definition at line 109 of file GPUimage.H.

◆ itsLocation

GLuint jevois::GPUimage::itsLocation = 0
protected

Definition at line 101 of file GPUimage.H.

◆ itsProgram

std::shared_ptr<GPUprogram> jevois::GPUimage::itsProgram
protected

Definition at line 96 of file GPUimage.H.

◆ itsTexture

std::shared_ptr<GPUtexture> jevois::GPUimage::itsTexture
protected

Definition at line 95 of file GPUimage.H.

◆ itsTextureHeight

unsigned int jevois::GPUimage::itsTextureHeight = 0
protected

Definition at line 107 of file GPUimage.H.

◆ itsTextureWidth

unsigned int jevois::GPUimage::itsTextureWidth = 0
protected

Definition at line 107 of file GPUimage.H.

◆ itsVertexArray

GLuint jevois::GPUimage::itsVertexArray = 0
protected

Definition at line 102 of file GPUimage.H.

◆ itsVertexBuffers

GLuint jevois::GPUimage::itsVertexBuffers[2] = { }
protected

Definition at line 103 of file GPUimage.H.


The documentation for this class was generated from the following files: