AURobotServers  4
Public Member Functions | Public Attributes | Protected Member Functions | Private Attributes | List of all members
UImgPush Class Reference

#include <uimgpush.h>

Inheritance diagram for UImgPush:
Inheritance graph

Public Member Functions

int addPoolPushCommand (UServerInMsg *msg)
 
void createLocalVariables (UVarPool *parent)
 
void fillBuffer (GstElement *fakesrc, GstBuffer *buffer, GstPad *pad)
 
void fillShowBuffer (GstElement *fakesrc, GstBuffer *buffer, GstPad *pad)
 
int getTcpPort ()
 
virtual void imgUpdated ()
 
void run ()
 
void runShow ()
 
void setImgLog (UImageLog *imageLog)
 
void setLogInterval (int interval)
 
bool setTcpPort (int port)
 
void startShowing (bool doStart)
 
void startStreaming (bool doStart)
 
 UImgPush (const unsigned int height=480, const unsigned int width=640, int channels=3, int depth=8)
 
virtual ~UImgPush ()
 
- Public Member Functions inherited from UImage
void clear (UPixel rgb)
 
void clear (void)
 
void clear (int v)
 
bool colorSaturate (double gain)
 
bool colourSaturate (double gain)
 
bool copy (UImage *source)
 
bool copyAndScale (UImage *source, double factor)
 
bool copyJustImage (UImage *source)
 
bool copyMeta (UImage *source, bool andSize)
 
bool copyScaleDown (UImage *source, int factor)
 
bool copyToMaxRes (UImage *source)
 
CvArr * cvArr ()
 
void edgeSobel (UImage *destination, bool absoluteValue=true, int reducFactor=1)
 
bool fromMat (char *colorFormatString=NULL)
 
bool fromMat (cv::Mat src, char *colorFormatString=NULL)
 
unsigned int getBufferSize ()
 Get number of bytes in image buffer. This is the total size of the allocated image buffer. This may be larger than the the number of bytes actually used by the image, and allows thus change in image size or format without allocating new buffer space. More...
 
int getChannels ()
 
char * getCharRef (unsigned int line, unsigned int column)
 
int getColorType ()
 
const char * getColorTypeString ()
 
UImage ** getConvertBuffer ()
 
UPixelgetData ()
 
unsigned int getDataSize ()
 
int getDepth ()
 
unsigned int getHeight ()
 
UTime getImageTime ()
 
int * getIntRef (unsigned int line, unsigned int column)
 
IplImage * getIplImage ()
 
UPixelgetLine (unsigned int line)
 
bool GetNewNonCameraImage ()
 
UPixel getPix (unsigned int line, unsigned int column)
 
UPixel getPix (unsigned int line, unsigned int column, int inColFormat)
 
int getPixInt (unsigned int line, unsigned int column)
 
UPixelgetPixRef (unsigned int line, unsigned int column)
 
bool getQuadPix (unsigned int line, unsigned int column, unsigned char *I11, unsigned char *I12, unsigned char *I21, unsigned char *I22, unsigned char *U, unsigned char *V)
 
unsigned char * getUCharRef (unsigned int line, unsigned int column)
 
unsigned char * getUline (unsigned int line)
 
UTime getUpdatedTime ()
 
unsigned char * getVline (unsigned int line)
 
unsigned int getWidth ()
 
unsigned char * getYline (unsigned int line)
 
void gridLine (float Pos, char axis, float minH, float maxH, float minW, float maxW, char sw= 'y', int Color=1)
 
void gridLines (float major, float minor, char axis, float minH, float maxH, float minW, float maxW, char sw)
 
unsigned int height ()
 
void hLine (unsigned int line, unsigned int c1, unsigned int c2, int p1, int p2, int p3)
 
unsigned int imgBytes ()
 
bool initImage (const unsigned int iHeight, const unsigned int iWidth, char *data, const unsigned int bufferSize, const int channels=3, const int depth=8)
 
bool inRange (int line, int column)
 
bool invertY ()
 
bool isBayer ()
 
bool isBGR ()
 
bool isBW ()
 
bool isBW16s ()
 
bool isBW16u ()
 
bool isRGB ()
 
bool isRGBA ()
 
bool isTooBig (const unsigned int w, const unsigned int h)
 
bool isValid ()
 
bool isYUV ()
 
bool isYUV420 ()
 
bool isYUV422 ()
 
void lineInGrid (UPosition pos1, UPosition pos2, float minH, float maxH, float minW, float maxW, char sw, UPixel *rgb, UMatrix4 *mA=NULL, int lineWidth=1)
 
bool loadBMP (const char filename[])
 
bool loadBMP (const char path[], const char basename[], const int num, const char nameAdd[])
 
bool loadPNG (const char *filename)
 
unsigned int maxBytes ()
 
unsigned int maxPixels ()
 
bool median (UImage *dimg, unsigned int row1, unsigned int col1, unsigned int row2, unsigned int col2, unsigned int fW, unsigned int fH)
 
void moveBW16ToRGB (UImage *dest)
 
int packZLIB (char *buffer, int bufferSize)
 
void paintGridAligned (const int r0, const int c0, const double pixPerM, const int strongTicEvery)
 
int pixCmp (UPixel *p1, UPixel *p2)
 
UPixel pixRGB (unsigned char r, unsigned char g, unsigned char b)
 
UPixelpixSort (UPixel ***ps, int pixCnt)
 
UPixel pixYUV (unsigned char y, unsigned char u, unsigned char v)
 
bool resize (const unsigned int iHeight, const unsigned int iWidth, const int channels=3, const int depth=8)
 
bool resizeBuffer (const unsigned int iHeight, const unsigned int iWidth, const int channels, const int depth)
 
bool saveBMP (const char filename[])
 
bool saveBMP (const char path[], const char basename[], const int num, const char nameAdd[])
 
bool saveMeta (const char *name, const char *type, const char *path)
 
bool savePNG (const char *filename)
 
bool saveTxt (const char *filename)
 
int setColorType (const char *)
 
bool setColorType (int colorFormat)
 
bool setMaxSize43 ()
 
void setName (const char *imageName)
 
void setNameAndExt (const char *basename, const char *ext=NULL)
 
void setPix (unsigned int line, unsigned int column, UPixel pix)
 
void setPixChar (unsigned int line, unsigned int column, char pix)
 
void setPixel (int x1, int y1, UPixel rgb, UImage *image=NULL, int procent=0)
 
void setPixInt (unsigned int line, unsigned int column, int pix)
 
void setPixUChar (unsigned int line, unsigned int column, unsigned char pix)
 
bool setQuadPix (unsigned int line, unsigned int column, unsigned char I11, unsigned char I12, unsigned char I21, unsigned char I22, unsigned char U, unsigned char V)
 
void setROI (int x, int y, int w, int h)
 
bool setSize (const unsigned int iHeight, const unsigned int iWidth, const int channels, const int depth, const char *colorType=NULL)
 
bool setSizeOnly (const unsigned int iHeight, const unsigned int iWidth)
 
void shiftCols (int cols, int byteFill=-1)
 
void shiftRows (int rows, int byteFill=-1)
 
UPixel sobel (UPixel *p1, UPixel *p2, UPixel *p3)
 
UPixel sobel (UPixel *p1, UPixel *p2, UPixel *p3, UPixel *pixRef, int reducFactor)
 
bool toBGR (UImage *dest=NULL)
 
bool toBW (UImage *dest=NULL)
 
bool toCromaBGR (UImage *dest=NULL)
 
bool toHalf ()
 
bool toMat ()
 
void tone (UPixel *rgb, int procent)
 
void tone (UPixel rgb, int procent)
 
bool toRaibow (UImage *gray)
 
bool toRaibowInv (UImage *gray)
 
bool toRGB (UImage *dest=NULL)
 
bool toRGBA (UImage *dest=NULL)
 
bool toYUV (UImage *dest=NULL)
 
 UImage ()
 
bool unpackZLIB (int rows, int cols, const char *colFormat, char *buffer, int bufferCnt)
 
void updated ()
 
void vLine (unsigned int col, unsigned int r1, unsigned int r2, int p1, int p2, int p3)
 
unsigned int width ()
 
bool yuv422toBGR (uint8_t *source, int h, int w)
 
bool yuv422toBGRhalf (uint8_t *source, int h, int w)
 
bool yuv422toBW (uint8_t *source, int h, int w)
 
bool yuv422toRGB (uint8_t *source, int h, int w)
 
bool yuv422toRGBhalf (uint8_t *source, int h, int w)
 
bool yuv422toYUV (uint8_t *source, int h, int w)
 
bool yuv422toYUVhalf (uint8_t *source, int h, int w)
 
virtual ~UImage ()
 
- Public Member Functions inherited from ULock
bool lock ()
 
void lockInit ()
 
void post ()
 
bool tryLock ()
 
bool tryWait ()
 
 ULock ()
 
void unlock ()
 
bool wait ()
 
 ~ULock ()
 
- Public Member Functions inherited from UServerPush
int addPushCommand (UServerInMsg *msg)
 
bool doPushCall (UServerPushElement *pe, const char *value)
 
void flushClientCmds (int clientIdx)
 
UServerPushImplementgetImplementor ()
 
int getPushCmdCnt (int *cmdCnt, int *callCnt)
 
UServerPushQueuegetPushQueue ()
 
bool gotCmdExe ()
 
void gotNewData (void *pData)
 
bool isUpdated (int lastCnt, int *newCnt)
 
bool needNewData ()
 
void print (const char *preString)
 
void print (const char *preString, char *buff, int buffCnt)
 
void servicePendingPushCmds ()
 
void setCmdExe (UServerPushImplement *executor)
 
void setImplementor (UServerPushImplement *executor)
 
bool setResource (UResBase *resource, bool remove)
 
bool setUpdated (const char *value)
 Add watch object if needed. An image or other object is updated. set object as updated, with an extra qualifier, that may be used as a parameter in a push call. this push list is then added to the to the push list examined by the server thread. when server thread reach this push list it will call to get a possible associated data structure by a call to needNewData() whish is expected to call gotNewData(void * data_structure) - but now in the server thread. More...
 
 UServerPush ()
 
virtual ~UServerPush ()
 

Public Attributes

int imgPoolNumber
 image pool slot More...
 
- Public Attributes inherited from UImage
void * cam
 
int camDevice
 
unsigned int hdrSet
 
unsigned long imageNumber
 
UTime imgTime
 
cv::Mat mat
 
char name [MAX_IMG_NAME_SIZE]
 
UPosition pos
 
bool radialErrorRemoved
 
float readDelay
 
URotation rot
 
char saveType [MAX_EXT_SIZE]
 
int source
 
unsigned int used
 
bool valid
 

Protected Member Functions

virtual void callGotNewDataWithObject ()
 
bool start ()
 
bool startShow ()
 
void stop (bool andWait)
 
void stopShow (bool andWait)
 
- Protected Member Functions inherited from UImage
bool moveBGGRTo (int toColFormat, UImage *dest)
 
bool moveBGGRtoBGR (UImage *dest)
 
bool moveBGGRtoBW (UImage *dest)
 
void moveBGGRToHalfBGR ()
 
bool moveBGGRtoRGB (UImage *dest)
 
void moveBWToHalf ()
 
void movePixToHalf ()
 
bool moveYUV420To (int toColFormat, UImage *dest)
 
void moveYUV420ToHalf ()
 
void moveYUV420ToHalf (UImage *dst)
 

Private Attributes

GMainLoop * gloop
 streamer loop - to be able to stop: More...
 
GMainLoop * gloop_show
 streamer loop - to be able to stop: More...
 
UImageLogimgLog
 logfile structure More...
 
int imgSizeH
 size of source image in pixels More...
 
int imgSizeW
 size of source image in pixels More...
 
UTime lastShowTime
 last image number More...
 
UTime lastUpdateTime
 actual framerate ?? used? More...
 
pthread_t threadHandle
 
bool threadRunning
 for image stream More...
 
pthread_t threadShowHandle
 
bool threadShowRunning
 is thread running - set by thread More...
 
bool threadShowStop
 is thread to stop - set by main function More...
 
bool threadStop
 is thread to stop - set by main function More...
 
UVariablevarDesiredUpdateRate
 (r/w) stream at this update interval More...
 
UVariablevarLogInterval
 update interval for logging More...
 
UVarPoolvarPoolParent
 link to global variable tree More...
 
UVariablevarSerial
 image serial number More...
 
UVariablevarShow
 (r/w) is streaming active More...
 
UVariablevarSize
 size of image More...
 
UVariablevarStreaming
 (r/w) is streaming active More...
 
UVariablevarTcpPort
 streaming port More...
 
UVariablevarTime
 image serial number More...
 
UVariablevarUdpClients
 UDP streaming clients. More...
 
UVariablevarUpdateCnt
 update count More...
 

Additional Inherited Members

- Static Public Member Functions inherited from UImage
static int toColFormatInt (const char *col)
 
- Protected Attributes inherited from UImage
unsigned int bufferBytes
 
int colFormat
 
IplImage img
 
UTime imgUpdateTime
 
unsigned char * pu
 
unsigned char * pv
 
unsigned char * py
 

Detailed Description

Image with push capabilities

Author
Christian Andersen

Constructor & Destructor Documentation

UImgPush::UImgPush ( const unsigned int  height = 480,
const unsigned int  width = 640,
int  channels = 3,
int  depth = 8 
)
UImgPush::~UImgPush ( )
virtual

Destructor

References stop().

Member Function Documentation

int UImgPush::addPoolPushCommand ( UServerInMsg msg)
inline

Add a camera push command. A camera push command is triggered when a new image is available.

References UServerPush::addPushCommand(), createLocalVariables(), imgUpdated(), and setTcpPort().

Referenced by UFunctionImgPool::handlePoolPushCommand().

virtual void UImgPush::callGotNewDataWithObject ( )
inlineprotectedvirtual

Called from push structure to get push object followed by a call to 'gotNewData(object)'. Returns false if no push commands are valid.

Reimplemented from UServerPush.

References fillBuffer(), fillShowBuffer(), UServerPush::gotNewData(), run(), runShow(), start(), startShow(), stop(), and stopShow().

void UImgPush::createLocalVariables ( UVarPool parent)

create local variables Should be called no more than once, and not if not to create global variables with status

Parameters
parentparent structure in global variable tree.

References UVarPool::addVar(), UVarPool::addVarA(), varDesiredUpdateRate, varLogInterval, varPoolParent, varSerial, varShow, varSize, varStreaming, varTcpPort, varTime, varUdpClients, and varUpdateCnt.

Referenced by addPoolPushCommand(), and UImagePool::getImage().

void UImgPush::fillBuffer ( GstElement *  fakesrc,
GstBuffer *  buffer,
GstPad *  pad 
)
void UImgPush::fillShowBuffer ( GstElement *  fakesrc,
GstBuffer *  buffer,
GstPad *  pad 
)
int UImgPush::getTcpPort ( )
inline

Get TCP port number for streaming

References UVariable::getInt(), and varTcpPort.

Referenced by UFunctionImgPool::handleImageSetCommand().

void UImgPush::imgUpdated ( )
virtual
void UImgPush::run ( )

stream thread using fake source - image-pool to stream assembles processing and starts gstreamer main thread,

Returns
when main loop is stopped, or an error occurred.

References cb_handoff(), FALSE, UImage::getChannels(), UImage::getDataSize(), UImage::getDepth(), UVariable::getInt(), UVariable::getString(), gloop, UImage::height(), UImage::isBayer(), UImage::isBW(), UImage::isRGB(), UVariable::setBool(), threadRunning, threadStop, TRUE, varStreaming, varTcpPort, varUdpClients, and UImage::width().

Referenced by callGotNewDataWithObject(), and startThread().

void UImgPush::runShow ( )

image show thread using fake source - image-pool to x-window assembles processing and starts gstreamer main thread,

Returns
when main loop is stopped, or an error occurred.

References cb_handoff_show(), FALSE, UImage::getChannels(), UImage::getDataSize(), UImage::getDepth(), UImage::getHeight(), UImage::getWidth(), gloop_show, UImage::height(), UImage::isBW(), UImage::isRGB(), UVariable::setBool(), threadShowRunning, threadShowStop, TRUE, varShow, and UImage::width().

Referenced by callGotNewDataWithObject(), and startShowThread().

void UImgPush::setImgLog ( UImageLog imageLog)
inline

Status change in stream Set reference to image log for image pool

References imgLog, and setLogInterval().

Referenced by UImagePool::setLogImg().

void UImgPush::setLogInterval ( int  interval)

Set log attributes for this image

Parameters
intervalis logging interval 0 is off, 1 is all updates 2 is every other ...

References UVariable::setInt(), and varLogInterval.

Referenced by setImgLog(), and UImagePool::setLogImg().

bool UImgPush::setTcpPort ( int  port)

Set TCP port number for streaming - disconnecting ant clients

References cb_handoff(), UVariable::getBool(), UVariable::setInt(), start(), startThread(), stop(), varStreaming, and varTcpPort.

Referenced by addPoolPushCommand(), and UImagePool::getImage().

bool UImgPush::start ( )
protected

stop read thread

Parameters
andWaitwaits until thread is terminated, when false, then the call returns when the stop flag is set (i.e. immidiately). Start stream processing thread

Start stream processing thread

References startThread(), threadHandle, threadRunning, and threadStop.

Referenced by callGotNewDataWithObject(), imgUpdated(), and setTcpPort().

bool UImgPush::startShow ( )
protected

Start gstream show thread

Start stream processing thread

References startShowThread(), threadShowHandle, threadShowRunning, and threadShowStop.

Referenced by callGotNewDataWithObject(), and imgUpdated().

void UImgPush::startShowing ( bool  doStart)
inline

start streaming, that is set the flag for stream start, but actual start requires that image is updated.

References imgUpdated(), UVariable::setBool(), and varShow.

Referenced by UImagePool::getImage(), and UFunctionImgPool::handleImageSetCommand().

void UImgPush::startStreaming ( bool  doStart)
inline

start streaming, that is set the flag for stream start, but actual start requires that image is updated.

References imgUpdated(), UVariable::setBool(), and varStreaming.

Referenced by UFunctionImgPool::handleImageSetCommand().

void UImgPush::stop ( bool  andWait)
protected

stop read thread

Parameters
andWaitwaits until thread is terminated, when false, then the call returns when the stop flag is set (i.e. immidiately).

References gloop, threadHandle, threadRunning, threadStop, and Wait().

Referenced by callGotNewDataWithObject(), imgUpdated(), setTcpPort(), and ~UImgPush().

void UImgPush::stopShow ( bool  andWait)
protected

stop read thread

Parameters
andWaitwaits until thread is terminated, when false, then the call returns when the stop flag is set (i.e. immidiately).

References gloop_show, threadShowHandle, threadShowRunning, threadShowStop, and Wait().

Referenced by callGotNewDataWithObject(), and imgUpdated().

Member Data Documentation

GMainLoop* UImgPush::gloop
private

streamer loop - to be able to stop:

Referenced by run(), stop(), and UImgPush().

GMainLoop* UImgPush::gloop_show
private

streamer loop - to be able to stop:

Referenced by runShow(), stopShow(), and UImgPush().

UImageLog* UImgPush::imgLog
private

logfile structure

Referenced by imgUpdated(), setImgLog(), and UImgPush().

int UImgPush::imgPoolNumber
int UImgPush::imgSizeH
private

size of source image in pixels

int UImgPush::imgSizeW
private

size of source image in pixels

UTime UImgPush::lastShowTime
private

last image number

Referenced by fillShowBuffer().

UTime UImgPush::lastUpdateTime
private

actual framerate ?? used?

last image number

Referenced by fillBuffer(), and fillShowBuffer().

pthread_t UImgPush::threadHandle
private

Thread handle for processing thread.

Referenced by start(), stop(), and UImgPush().

bool UImgPush::threadRunning
private

for image stream

is thread running - set by thread

Referenced by imgUpdated(), run(), start(), stop(), and UImgPush().

pthread_t UImgPush::threadShowHandle
private

Thread handle for processing thread.

Referenced by startShow(), stopShow(), and UImgPush().

bool UImgPush::threadShowRunning
private

is thread running - set by thread

Referenced by imgUpdated(), runShow(), startShow(), stopShow(), and UImgPush().

bool UImgPush::threadShowStop
private

is thread to stop - set by main function

Referenced by fillShowBuffer(), runShow(), startShow(), stopShow(), and UImgPush().

bool UImgPush::threadStop
private

is thread to stop - set by main function

Referenced by fillBuffer(), run(), start(), stop(), and UImgPush().

UVariable* UImgPush::varDesiredUpdateRate
private

(r/w) stream at this update interval

Referenced by createLocalVariables(), fillBuffer(), fillShowBuffer(), and UImgPush().

UVariable* UImgPush::varLogInterval
private

update interval for logging

Referenced by createLocalVariables(), imgUpdated(), and setLogInterval().

UVarPool* UImgPush::varPoolParent
private

link to global variable tree

Referenced by createLocalVariables(), imgUpdated(), and UImgPush().

UVariable* UImgPush::varSerial
private

image serial number

Referenced by createLocalVariables(), imgUpdated(), and UImgPush().

UVariable* UImgPush::varShow
private

(r/w) is streaming active

Referenced by createLocalVariables(), fillShowBuffer(), imgUpdated(), runShow(), startShowing(), and UImgPush().

UVariable* UImgPush::varSize
private

size of image

Referenced by createLocalVariables(), imgUpdated(), and UImgPush().

UVariable* UImgPush::varStreaming
private
UVariable* UImgPush::varTcpPort
private

streaming port

Referenced by createLocalVariables(), getTcpPort(), run(), setTcpPort(), and UImgPush().

UVariable* UImgPush::varTime
private

image serial number

Referenced by createLocalVariables(), imgUpdated(), and UImgPush().

UVariable* UImgPush::varUdpClients
private

UDP streaming clients.

Referenced by createLocalVariables(), and run().

UVariable* UImgPush::varUpdateCnt
private

update count

Referenced by createLocalVariables(), and imgUpdated().


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