13 ptr_portCallback =
nullptr;
14 setOptionsToDefault();
16 _pOutRightPort =
nullptr;
21 connect(&sigHandler,
SIGNAL(sendFps(
double,
double,
double,
double,
double,
double)),
22 this,
SLOT(onSendFps(
double,
double,
double,
double,
double,
double)));
25 this,
SLOT(onWindowSizeChangeRequested()));
158void QtYARPView::periodToFreq(
double avT,
double mT,
double MT,
double &
avH,
double &
mH,
double &
MH)
189 QString::number(
pMin,
'f',1),
190 QString::number(
pMax,
'f',1));
193 QString::number(
dMin,
'f',1),
194 QString::number(
dMax,
'f',1));
208void QtYARPView::createObjects() {
209#ifdef YARP_LITTLE_ENDIAN
219void QtYARPView::deleteObjects() {
220 if (ptr_inputPort !=
nullptr) {
221 delete ptr_inputPort;
223 if (ptr_portCallback !=
nullptr) {
224 delete ptr_portCallback;
234 int c = params.count();
236 v = (
char**)
malloc(
sizeof(
char*) *
c);
238 for(
int i=0;i<params.count();i++){
239 v[i] =
strdup(params.at(i).toLatin1().data());
244 for(
int i=0;i<params.count();i++) {
250 if (options.
check(
"help"))
257 qCritical(
"Cannot connect to yarp server");
265 qDebug(
"Error open ports");
276 if (options.
check(
"PortName",val)||options.
check(
"name",val)) {
280 if (options.
check(
"Title",val)||options.
check(
"title",val)) {
285 if(options.
check(
"compact")){
289 if (options.
check(
"NetName",val)||options.
check(
"n",val)) {
292 if (options.
check(
"OutPortName",val)||options.
check(
"out",val)) {
295 if (options.
check(
"OutRightPortName",val)||options.
check(
"rightout",val)) {
299 if (options.
check(
"OutNetName",val)||options.
check(
"neto",val)) {
302 if (options.
check(
"RefreshTime",val)||options.
check(
"p",val)) {
307 if (options.
check(
"PosX",val)||options.
check(
"x",val)) {
311 if (options.
check(
"PosY",val)||options.
check(
"y",val)) {
315 if (options.
check(
"Width",val)||options.
check(
"w",val)) {
319 if (options.
check(
"Height",val)||options.
check(
"h",val)) {
323 if (options.
check(
"OutputEnabled",val)) {
326 if (options.
check(
"out",val)) {
329 if (options.
check(
"SaveOptions",val)||options.
check(
"saveoptions",val)) {
332 if (options.
check(
"synch"))
338 if (options.
check(
"autosize"))
349void QtYARPView::printHelp()
351 qDebug(
"yarpview usage:");
352 qDebug(
" --name: input port name (default: /yarpview/img:i)");
353 qDebug(
" --title: A title for the yarpview window");
355 qDebug(
" - compact flag enabled: input port name");
356 qDebug(
" - compact flag disabled: \"YARP Qt Image Viewer\"");
358 qDebug(
" --x: x position of the window in the screen");
359 qDebug(
" --y: y position of the window in the screen");
360 qDebug(
" --w: width of the window");
361 qDebug(
" --h: height of the window");
362 qDebug(
" --p: refresh time [ms]");
363 qDebug(
" --synch: synchronous display, every image received by the input port is displayed");
364 qDebug(
" --autosize: the display automatically resizes on every new frame");
365 qDebug(
" --out: output port name (no default is given, if this option is not specified the port is not created)");
366 qDebug(
" --rightout: output port for right click name (no default is given, if this option is not specified the port is not created)");
367 qDebug(
" --neto: output network");
368 qDebug(
" --neti: input network");
369 qDebug(
" --compact: if this flag is enabled, no status bar will be showed");
370 qDebug(
" --minimal: if this flag is enabled, neither the status bars nor the title bar/menu bar will be showed. It overwrites --compact.");
371 qDebug(
" --keep-above: keep windows above others");
375void QtYARPView::setOptionsToDefault()
408bool QtYARPView::openPorts()
418 qDebug(
"Error: port failed to open, quitting.");
427 qDebug(
"Port registration succeed!");
431 qDebug(
"ERROR: Port registration failed.\nQuitting, sorry.");
441 qDebug(
"Port registration succeed!");
444 _pOutRightPort =
nullptr;
445 qDebug(
"ERROR: Port registration failed.\nQuitting, sorry.");
454void QtYARPView::closePorts()
457 ptr_inputPort->
close();
472 _pOutRightPort->
close();
479 delete _pOutRightPort;
480 _pOutRightPort =
nullptr;
487void QtYARPView::saveOptFile(
char *fileName)
492 bool opened =
optFile.
open(QIODevice::WriteOnly | QIODevice::Truncate);
494 qDebug(
"ERROR: Impossible to save to option file.");
515 int imageWidth, imageHeight;
520 if ((imageWidth != 0) && (imageHeight != 0)) {
521 qDebug(
"Transmitting click information...");
522 if (_pOutPort !=
nullptr) {
535 qDebug(
"I would send a position, but there's no image for scaling");
541 int imageWidth, imageHeight;
546 if ( (imageWidth != 0) && (imageHeight != 0) ) {
547 qDebug(
"Transmitting click information...");
548 if (_pOutPort!=
nullptr) {
558 qDebug(
"I would send a position, but there's no image for scaling");
564 int imageWidth, imageHeight;
569 if ((imageWidth != 0) && (imageHeight != 0)) {
570 qDebug(
"Transmitting click information...");
571 if (_pOutRightPort !=
nullptr) {
579 _pOutRightPort->
write();
584 qDebug(
"I would send a position, but there's no image for scaling");
590 int imageWidth, imageHeight;
595 if ( (imageWidth != 0) && (imageHeight != 0) ) {
596 qDebug(
"Transmitting click information...");
597 if (_pOutRightPort!=
nullptr) {
603 _pOutRightPort->
write();
607 qDebug(
"I would send a position, but there's no image for scaling");
616void QtYARPView::onWindowSizeChangeRequested()
int SIGNAL(int pid, int signum)
int posX
Returns the x position from the options.
Q_INVOKABLE void setFilesName(QUrl url)
Sets the current filename of the frame set is going to be saved.
void setName(QString name)
Q_INVOKABLE void clickCoords_4(int start_x, int start_y, int end_x, int end_y)
Q_INVOKABLE QString getPixelAsStr(int x, int y)
Pics the rgb value of the pixel specified by x and y and return it as a string.
Q_INVOKABLE void saveFrame()
Saves the current frame.
void setTitle(QString inputTitle)
Q_INVOKABLE void clickCoords_2(int x, int y)
Q_INVOKABLE void rightClickCoords_2(int x, int y)
int posY
Returns the y position from the options.
void autosize(bool check)
Q_INVOKABLE void startDumpFrames()
Saves the current frame set.
int windowWidth
Returns the width from the options.
Q_INVOKABLE bool rightClickEnabled()
int windowHeight
Returns the height from the options.
void refreshIntervalChanged()
void synchRate(bool check)
Q_INVOKABLE void stopDumpFrames()
Stops the current frame set save mode.
void sendPortFps(QString avg, QString min, QString max)
Q_INVOKABLE void rightClickCoords_4(int start_x, int start_y, int end_x, int end_y)
Q_INVOKABLE void synchDisplayPeriod(bool check)
Synchs the video stream to the display.
QtYARPView(QQuickItem *parent=0)
Q_INVOKABLE void setFileName(QUrl url)
Sets the current filename of the frame is going to be saved.
Q_INVOKABLE void changeRefreshInterval(int)
Changes the refresh interval.
void sendDisplayFps(QString avg, QString min, QString max)
Q_INVOKABLE void synchDisplaySize(bool check)
Synchs the size of the window with the size of the video stream.
Q_INVOKABLE bool parseParameters(QStringList)
parse the parameters received from the main container in QstringList form
QObject * getVideoProducer()
returns the videoproducer that acts as bridge between C++ code and QML VideoOutput.
int refreshInterval
Gets the refresh interval from options.
Q_INVOKABLE void freeze(bool check)
Freeze the video stream.
void setFileNames(QUrl url)
Sets the filename used for saving a video frame set.
void stopDumpFrames()
Stops the Dump frame modality (Save frame set).
void saveCurrentFrame()
Enable the save curretn frame mode.
void changeRefreshInterval(int ineterval)
Sets the refresh interval.
void freeze(bool check)
Enable/Disable the freeze mode.
void setFileName(QUrl url)
Sets the filename used for saving a video frame.
void startDumpFrames()
Enables the Dump frame modality (Save frame set).
void synchDisplayPeriod(bool check)
Enable/Disable the synch mode.
void synchDisplaySize(bool check)
Enable/Disable the synch size mode.
A simple collection of objects that can be described and transmitted in a portable way.
void clear()
Empties the bottle of any objects it contains.
void addInt32(std::int32_t x)
Places a 32-bit integer in the bottle, at the end of the list.
A mini-server for performing network communication in the background.
std::string getName() const override
Get name of port.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
void useCallback(TypedReaderCallback< T > &callback) override
Set an object whose onRead method will be called when data is available.
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
T & prepare()
Access the object which will be transmitted by the next call to yarp::os::BufferedPort::write.
static bool checkNetwork()
Check if the YARP Network is up and running.
A class for storing options and configuration information.
bool check(const std::string &key) const override
Check if there exists a property of the given name.
void fromCommand(int argc, char *argv[], bool skipFirst=true, bool wipe=true)
Interprets a list of command arguments as a list of properties.
A base class for nested structures that can be searched.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
A single value (typically within a Bottle).
virtual std::int32_t asInt32() const
Get 32-bit integer value.
virtual std::string asString() const
Get string value.
An interface to the operating system, including Port based communication.
The main, catch-all namespace for YARP.
unsigned int m_refreshTime
char m_outNetworkName[256]
char m_outRightPortName[256]