YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
9#include <yarp/os/PortInfo.h>
11#include <yarp/os/RFModule.h>
12#include <yarp/os/Stamp.h>
13#include <yarp/sig/all.h>
14
15#include <iostream>
16#include <iomanip>
17#include <fstream>
18#include <sstream>
19#include <string>
20#include <array>
21#include <deque>
22#include <utility>
23#include <mutex>
24#include <algorithm>
25
26#ifdef ADD_VIDEO
27# include <opencv2/opencv.hpp>
28# include <yarp/cv/Cv.h>
29# include <opencv2/core/core_c.h>
30# include <opencv2/videoio.hpp>
31#endif // ADD_VIDEO
32
33
34using namespace yarp::os;
35using namespace yarp::sig;
36
37#ifdef ADD_VIDEO
38 using namespace yarp::cv;
39#endif
40
41/**************************************************************************/
43
44// Abstract object definition for queuing
45/**************************************************************************/
47{
48protected:
50
51public:
52 virtual ~DumpObj() = default;
53 virtual const std::string toFile(const std::string&, unsigned int) = 0;
54 virtual void attachFormat(const DumpFormat &format) { m_dump_format=format; }
55};
56
57
58// Specialization for Bottle object
59/**************************************************************************/
60class DumpBottle : public DumpObj
61{
62private:
63 Bottle *p;
64
65public:
66 DumpBottle() { p=new Bottle; }
67 DumpBottle(const DumpBottle &obj) { p=new Bottle(*(obj.p)); }
68 DumpBottle(const Bottle &b) { p=new Bottle(b); }
69 const DumpBottle &operator=(const DumpBottle &obj) { *p=*(obj.p); return *this; }
70 ~DumpBottle() { delete p; }
71
72 const std::string toFile(const std::string &dirName, unsigned int cnt) override
73 {
74 std::string ret=p->toString();
75 return ret;
76 }
77};
78
79
80// Object creator of type Bottle - overloaded
81/**************************************************************************/
83{
84 auto* p=new DumpBottle(obj);
85 return p;
86}
87
88
89// Specialization for Image object
90/**************************************************************************/
91class DumpImage : public DumpObj
92{
93private:
94 Image *p;
95#ifdef ADD_VIDEO
96 cv::Mat img;
97#endif
98
99public:
100 DumpImage() { p=new Image(); }
101 DumpImage(const DumpImage &obj) { p=new Image(*(obj.p)); }
102 DumpImage(const Image &img) { p=new Image(img); }
103 const DumpImage &operator=(const DumpImage &obj) { *p=*(obj.p); return *this; }
104 ~DumpImage() { delete p; }
105
106 const std::string toFile(const std::string &dirName, unsigned int cnt) override
107 {
109 std::string ext;
110
111 int code=p->getPixelCode();
112 switch (code)
113 {
114 //depth images
117 {
119 ext = ".float";
120 }
122 {
124 ext = ".floatzip";
125 }
126 break;
127
128 //grayscale images
129 case VOCAB_PIXEL_MONO:
131 {
133 ext = ".png";
134 }
135 else
136 {
138 ext = ".pgm";
139 }
140 break;
141
142 //rgb, bgr and other type of color images
143 default:
145 {
147 ext = ".jpg";
148 }
150 {
152 ext = ".png";
153 }
154 else
155 {
157 ext = ".ppm";
158 }
159 break;
160 }
161
162 std::ostringstream fName;
163 fName << std::setw(8) << std::setfill('0') << cnt << ext;
164 file::write(*p,dirName+"/"+fName.str(), fileformat);
165
166 return (fName.str()+" ["+Vocab32::decode(code)+"]");
167 }
168
169#ifdef ADD_VIDEO
170 const cv::Mat &getImage()
171 {
172 int code=p->getPixelCode();
173 if (code==VOCAB_PIXEL_MONO_FLOAT)
174 {
175 img=toCvMat(*static_cast<ImageOf<PixelFloat>*>(p));
176 }
177 else if (code==VOCAB_PIXEL_MONO)
178 {
179 img=toCvMat(*static_cast<ImageOf<PixelMono>*>(p));
180 }
181 else
182 {
183 img=toCvMat(*static_cast<ImageOf<PixelRgb>*>(p));
184 }
185 return img;
186 }
187#endif
188};
189
190
191// Object creator of type Image - overloaded
192/**************************************************************************/
194{
195 auto* p=new DumpImage(obj);
196 return p;
197}
198
199
200// Class to manage tx and rx time stamps
201/**************************************************************************/
203{
204 double rxStamp{0.0};
205 double txStamp{0.0};
206 bool rxOk{false};
207 bool txOk{false};
208
209public:
210 DumpTimeStamp() = default;
211
212 void setRxStamp(const double stamp) { rxStamp=stamp; rxOk=true; }
213 void setTxStamp(const double stamp) { txStamp=stamp; txOk=true; }
214 double getStamp() const
215 {
216 if (txOk) {
217 return txStamp;
218 } else if (rxOk) {
219 return rxStamp;
220 } else {
221 return -1.0;
222 }
223 }
224 std::string getString() const
225 {
226 std::ostringstream ret;
227 ret<<std::fixed;
228
229 if (txOk) {
230 ret << txStamp;
231 }
232 if (rxOk)
233 {
234 if (!ret.str().empty()) {
235 ret << ' ';
236 }
237 ret<<rxStamp;
238 }
239 return ret.str();
240 }
241};
242
243
244// Definition of item to be put in the queue
245/**************************************************************************/
252
253
254// Definition of the queue
255// Two services act on this resource:
256// 1) the port, which listens to incoming data
257// 2) the thread, which stores the data to disk
258/**************************************************************************/
259class DumpQueue : public std::deque<DumpItem>
260{
261private:
262 std::mutex mutex;
263
264public:
265 void lock() { mutex.lock(); }
266 void unlock() { mutex.unlock(); }
267};
268
269
270/**************************************************************************/
271template <class T>
272class DumpPort : public BufferedPort<T>
273{
274public:
275 DumpPort(DumpQueue &Q, unsigned int _dwnsample=1,
276 bool _rxTime=true, bool _txTime=false, DumpFormat _dataformat= DumpFormat::bottle) : buf(Q)
277 {
278 rxTime=_rxTime;
279 txTime=_txTime;
280 dwnsample=_dwnsample>0?_dwnsample:1;
281 cnt=0;
282 itemformat = _dataformat;
283 firstIncomingData=true;
284 }
285
286private:
287 DumpQueue &buf;
288 unsigned int dwnsample;
289 unsigned int cnt;
290 bool firstIncomingData;
291 bool rxTime;
292 bool txTime;
293 DumpFormat itemformat;
294
295 using BufferedPort<T>::onRead;
296 void onRead(T &obj) override
297 {
298 if (++cnt==dwnsample)
299 {
300 if (firstIncomingData)
301 {
302 yInfo() << "Incoming data detected";
303 firstIncomingData=false;
304 }
305
307 Stamp info;
308
310 item.seqNumber=info.getCount();
311
312 if (txTime || (info.isValid() && !rxTime)) {
313 item.timeStamp.setTxStamp(info.getTime());
314 }
315
316 if (rxTime || !info.isValid()) {
317 item.timeStamp.setRxStamp(Time::now());
318 }
319
320 item.obj=factory(obj);
321 item.obj->attachFormat(itemformat);
322
323 buf.lock();
324 buf.push_back(item);
325 buf.unlock();
326
327 cnt=0;
328 }
329 }
330};
331
332
333/**************************************************************************/
335{
336private:
337 DumpQueue &buf;
338 DumpFormat type;
339 std::ofstream finfo;
340 std::ofstream fdata;
341 std::string dirName;
342 std::string infoFile;
343 std::string dataFile;
344 unsigned int blockSize;
345 unsigned int cumulSize;
346 unsigned int counter;
347 double oldTime;
348
349 bool saveData;
350 bool videoOn;
351 std::string videoType;
352 bool rxTime;
353 bool txTime;
354 bool closing;
355
356#ifdef ADD_VIDEO
357 std::ofstream ftimecodes;
358 std::string videoFile;
359 std::string timecodesFile;
360 double t0;
362 bool doSaveFrame;
363 cv::VideoWriter videoWriter;
364#endif
365
366public:
367 DumpThread(DumpFormat _type, DumpQueue &Q, const std::string &_dirName, const int szToWrite,
368 const bool _saveData, const bool _videoOn, const std::string &_videoType,
369 const bool _rxTime, const bool _txTime) :
370 PeriodicThread(0.05),
371 buf(Q),
372 type(_type),
373 dirName(std::move(_dirName)),
374 blockSize(szToWrite),
375 cumulSize(0),
376 counter(0),
377 oldTime(0.0),
378 saveData(_saveData),
379 videoOn(_videoOn),
380 videoType(std::move(_videoType)),
381 rxTime(_rxTime),
382 txTime(_txTime),
383 closing(false)
384 {
385 infoFile=dirName;
386 infoFile+="/info.log";
387
388 dataFile=dirName;
389 dataFile+="/data.log";
390
391 #ifdef ADD_VIDEO
392 t0 = 0.0;
393 transform(videoType.begin(),videoType.end(),videoType.begin(),::tolower);
394 if ((videoType!="mkv") && (videoType!="avi"))
395 {
396 yWarning() << "unknown video type '" << videoType << "' specified; "
397 << "'mkv' type will be used.";
398 videoType="mkv";
399 }
400
401 videoFile=dirName;
402 videoFile+="/video.";
403 videoFile+=videoType;
404
405 timecodesFile=dirName;
406 timecodesFile+="/timecodes.log";
407
408 doImgParamsExtraction=videoOn;
409 doSaveFrame=false;
410 #endif
411 }
412
413 void writeSource(const std::string &sourceName, const bool connected)
414 {
415 finfo << "[" << std::fixed << Time::now() << "] ";
416 finfo << sourceName << " ";
417 finfo << (connected?"[connected]":"[disconnected]") << '\n';
418 }
419
420 bool threadInit() override
421 {
422 oldTime=Time::now();
423
424 finfo.open(infoFile.c_str());
425 if (!finfo.is_open())
426 {
427 yError() << "unable to open file: " << infoFile;
428 return false;
429 }
430
431 finfo<<"Type: ";
432 if (type == DumpFormat::bottle) {
433 finfo<<"Bottle;";
434 } else if (type == DumpFormat::image) {
436 finfo<<"Image;";
437 if (videoOn) {
438 finfo << " Video:" << videoType << "(huffyuv);";
439 }
440 } else if (type == DumpFormat::depth) {
441 finfo << "Depth;";
442 } else if (type == DumpFormat::depth_compressed) {
443 finfo << "DepthCompressed;";
444 } else if (type == DumpFormat::image_jpg) {
445 finfo << "Image:jpg;";
446 } else if (type == DumpFormat::image_png) {
447 finfo << "Image:png;";
448 } else {
449 yError() << "I should not reach this line! Unknown data type" << (int)type;
450 }
451 finfo<<'\n';
452
453 finfo<<"Stamp: ";
454 if (txTime && rxTime) {
455 finfo<<"tx+rx;";
456 } else if (txTime) {
457 finfo<<"tx;";
458 } else {
459 finfo << "rx;";
460 }
461 finfo<<'\n';
462
463 fdata.open(dataFile.c_str());
464 if (!fdata.is_open())
465 {
466 yError() << "unable to open file: " << dataFile;
467 return false;
468 }
469
470 #ifdef ADD_VIDEO
471 if (videoOn)
472 {
474 if (!ftimecodes.is_open())
475 {
476 yError() << "unable to open file: " << timecodesFile;
477 return false;
478 }
479 ftimecodes<<"# timecode format v2\n";
480 }
481 #endif
482
483 return true;
484 }
485
486 void run() override
487 {
489 buf.lock();
490 unsigned int sz=(unsigned int)buf.size();
491 buf.unlock();
492
493 // each 10 seconds it issues a writeToDisk command straightaway
494 bool writeToDisk=false;
495 double curTime=Time::now();
496 if ((curTime-oldTime>10.0) || closing)
497 {
498 writeToDisk=sz>0;
499 oldTime=curTime;
500 }
501
502 // it performs the writeToDisk on command or as soon as
503 // the queue size is greater than the given threshold
504 if ((sz>blockSize) || writeToDisk)
505 {
506 #ifdef ADD_VIDEO
507 // extract images parameters just once
508 if (doImgParamsExtraction && (sz>1))
509 {
510 buf.lock();
511 DumpItem itemFront=buf.front();
512 DumpItem itemEnd=buf.back();
513 buf.unlock();
514
515 int fps;
516 auto& img=static_cast<DumpImage*>(itemEnd.obj)->getImage();
517 int frameW=img.size().width;
518 int frameH=img.size().height;
519
520 t0=itemFront.timeStamp.getStamp();
521 double dt=itemEnd.timeStamp.getStamp()-t0;
522 fps=(dt<=0.0)?25:int(double(sz-1)/dt);
523
524 videoWriter.open(videoFile.c_str(),cv::VideoWriter::fourcc('H','F','Y','U'),
525 fps,cvSize(frameW,frameH),true);
526
528 doSaveFrame=true;
529 }
530 #endif
531
532 // save to disk
533 for (unsigned int i=0; i<sz; i++)
534 {
535 buf.lock();
536 DumpItem item=buf.front();
537 buf.pop_front();
538 buf.unlock();
539
540 fdata << item.seqNumber << ' ' << item.timeStamp.getString() << ' ';
541 if (saveData) {
542 fdata << item.obj->toFile(dirName,counter++) << '\n';
543 } else {
544 std::ostringstream frame;
545 frame << "frame_" << std::setw(8) << std::setfill('0') << counter++;
546 fdata << frame.str() << '\n';
547 }
548
549#ifdef ADD_VIDEO
550 if (doSaveFrame)
551 {
553
554 // write the timecode of the frame
555 int dt=(int)(1000.0*(item.timeStamp.getStamp()-t0));
556 ftimecodes << dt << '\n';
557 }
558 #endif
559
560 delete item.obj;
561 }
562
563 cumulSize+=sz;
564 yInfo() << sz << " items stored [cumul #: " << cumulSize << "]";
565 }
566 }
567
568 void threadRelease() override
569 {
570 // call run() for the last time to flush the queue
571 closing=true;
572 run();
573
574 finfo.close();
575 fdata.close();
576
577 #ifdef ADD_VIDEO
578 if (videoOn) {
580 }
581#endif
582 }
583};
584
585
586/**************************************************************************/
588{
589private:
590 DumpThread *thread{nullptr};
591
592public:
593 DumpReporter() = default;
594 void setThread(DumpThread *thread) { this->thread=thread; }
595 void report(const PortInfo &info) override
596 {
597 if ((thread != nullptr) && info.incoming) {
598 thread->writeSource(info.sourceName, info.created);
599 }
600 }
601};
602
603
604/**************************************************************************/
605class DumpModule: public RFModule
606{
607private:
608 DumpQueue *q{nullptr};
609 DumpPort<Bottle> *p_bottle{nullptr};
610 DumpPort<Image> *p_image{nullptr};
611 DumpThread *t{nullptr};
612 DumpReporter reporter;
613 Port rpcPort;
615 bool rxTime{false};
616 bool txTime{false};
617 unsigned int dwnsample{0};
618 std::string portName;
619
620 void polish_filename(std::string &fname)
621 {
622 std::array<char,6> notallowed={':','*','?','|','>','<'};
623 for (const auto& c : notallowed)
624 {
625#if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
626 replace(fname.begin(),fname.end(),c,'_');
627#else
628 auto it = fname.begin();
629 for (; it != fname.end(); ++it) {
630 if (*it == c) {
631 *it = '_';
632 }
633 }
634#endif
635 }
636 }
637
638public:
639 DumpModule() = default;
640
641 bool configure(ResourceFinder &rf) override
642 {
643 portName=rf.check("name",Value("/dump")).asString();
644 if (portName[0] != '/') {
645 portName = "/" + portName;
646 }
647
648 bool saveData=true;
649 bool videoOn=false;
650 std::string videoType=rf.check("videoType",Value("mkv")).asString();
651
652 if (rf.check("type"))
653 {
654 std::string optTypeName=rf.find("type").asString();
655 if (optTypeName=="bottle")
656 {
657 dumptype = DumpFormat::bottle;
658 }
659 else if (optTypeName == "depth")
660 {
661 dumptype = DumpFormat::depth;
662 }
663 else if (optTypeName == "depth_compressed")
664 {
666 }
667 else if ((optTypeName == "image"))
668 {
669 dumptype = DumpFormat::image;
670 #ifdef ADD_VIDEO
671 if (rf.check("addVideo")) {
672 videoOn = true;
673 }
674#endif
675 }
676 else if ((optTypeName == "image_jpg"))
677 {
678 dumptype = DumpFormat::image_jpg;
679 #ifdef ADD_VIDEO
680 if (rf.check("addVideo")) {
681 videoOn = true;
682 }
683#endif
684 }
685 else if ((optTypeName == "image_png"))
686 {
687 dumptype = DumpFormat::image_png;
688 #ifdef ADD_VIDEO
689 if (rf.check("addVideo")) {
690 videoOn = true;
691 }
692#endif
693 }
694 #ifdef ADD_VIDEO
695 else if (optTypeName=="video")
696 {
697 dumptype = DumpFormat::image;
698 videoOn=true;
699 saveData=false;
700 }
701 #endif
702 else
703 {
704 yError() << "Error: invalid type";
705 return false;
706 }
707 }
708 else
709 {
710 dumptype = DumpFormat::bottle;
711 }
712
713 dwnsample=rf.check("downsample",Value(1)).asInt32();
714 rxTime=rf.check("rxTime");
715 txTime=rf.check("txTime");
716 std::string templateDirName=rf.check("dir")?rf.find("dir").asString():portName;
717 polish_filename(templateDirName);
718 if (templateDirName[0] != '/') {
720 }
721
722 std::string dirName;
723 if (rf.check("overwrite")) {
724 dirName="."+templateDirName;
725 } else {
726 // look for a proper directory
727 int i=0;
728 do
729 {
730 std::ostringstream checkDirName;
731 if (i > 0) {
732 checkDirName << "." << templateDirName << "_" << std::setw(5) << std::setfill('0') << i;
733 } else {
735 }
736
737 dirName=checkDirName.str();
738 i++;
739 }
740 while (!yarp::os::stat(dirName.c_str()));
741 }
742 yarp::os::mkdir_p(dirName.c_str());
743
744 q=new DumpQueue();
745 t=new DumpThread(dumptype,*q,dirName,100,saveData,videoOn,videoType,rxTime,txTime);
746
747 if (!t->start())
748 {
749 delete t;
750 delete q;
751
752 return false;
753 }
754
755 reporter.setThread(t);
756
757 if (dumptype == DumpFormat::bottle)
758 {
759 p_bottle=new DumpPort<Bottle>(*q,dwnsample,rxTime,txTime, DumpFormat::bottle);
760 p_bottle->useCallback();
761 p_bottle->open(portName);
762 p_bottle->setStrict();
763 p_bottle->setReporter(reporter);
764 }
765 else
766 {
767 p_image=new DumpPort<Image>(*q,dwnsample,rxTime,txTime, dumptype);
768 p_image->useCallback();
769 p_image->open(portName);
770 p_image->setStrict();
771 p_image->setReporter(reporter);
772 }
773
774 if (rf.check("connect"))
775 {
776 std::string srcPort=rf.find("connect").asString();
777 bool ok=Network::connect(srcPort.c_str(),
778 (dumptype == DumpFormat::bottle)? p_bottle->getName().c_str() : p_image->getName().c_str(),
779 "tcp");
780
781 std::ostringstream msg;
782 msg << "Connection to " << srcPort << " " << (ok?"successful":"failed");
783
784 if (ok) {
785 yInfo() << msg.str();
786 } else {
787 yWarning() << msg.str();
788 }
789 }
790
791 // this port serves to handle the "quit" rpc command
792 rpcPort.open(portName+"/rpc");
793 attach(rpcPort);
794
795 yInfo() << "Service yarp port: " << portName;
796 yInfo() << "Data stored in : " << dirName;
797
798 return true;
799 }
800
801 bool close() override
802 {
803 t->stop();
804
805 if (dumptype == DumpFormat::bottle)
806 {
807 p_bottle->interrupt();
808 p_bottle->close();
809 delete p_bottle;
810 }
811 else
812 {
813 p_image->interrupt();
814 p_image->close();
815 delete p_image;
816 }
817
818 rpcPort.interrupt();
819 rpcPort.close();
820
821 delete t;
822 delete q;
823
824 return true;
825 }
826
827 double getPeriod() override { return 1.0; }
828 bool updateModule() override { return true; }
829};
830
831
832/**************************************************************************/
833int main(int argc, char *argv[])
834{
836
838 rf.configure(argc,argv);
839
840 if (rf.check("help"))
841 {
842 yInfo() << "Options:";
843 yInfo() << "\t--name port: service port name (default: /dump)";
844 yInfo() << "\t--connect port: name of the port to connect the dumper to at launch time";
845 yInfo() << "\t--dir name: provide explicit name of storage directory";
846 yInfo() << "\t--overwrite : overwrite pre-existing storage directory";
847 #ifdef ADD_VIDEO
848 yInfo() << "\t--type type: type of the data to be dumped [bottle(default), image, image_jpg, image_png, video, depth, depth_compressed]";
849 yInfo() << "\t--addVideo : produce video as well (if image* is selected)";
850 yInfo() << "\t--videoType ext: produce video of specified container type [mkv(default), avi]";
851 #else
852 yInfo() << "\t--type type: type of the data to be dumped [bottle(default), image, image_jpg, image_png, depth, depth_compressed]";
853 #endif
854 yInfo() << "\t--downsample n: downsample rate (default: 1 => downsample disabled)";
855 yInfo() << "\t--rxTime : dump the receiver time instead of the sender time";
856 yInfo() << "\t--txTime : dump the sender time straightaway";
857 yInfo();
858
859 return 0;
860 }
861
862 if (!yarp.checkNetwork())
863 {
864 yError()<<"YARP server not available!";
865 return 1;
866 }
867
869 return mod.runModule(rf);
870}
@ VOCAB_PIXEL_MONO_FLOAT
Definition Image.h:53
@ VOCAB_PIXEL_MONO
Definition Image.h:42
bool ret
#define yInfo(...)
Definition Log.h:319
#define yError(...)
Definition Log.h:361
#define yWarning(...)
Definition Log.h:340
DumpBottle(const Bottle &b)
Definition main.cpp:68
DumpBottle()
Definition main.cpp:66
DumpBottle(const DumpBottle &obj)
Definition main.cpp:67
~DumpBottle()
Definition main.cpp:70
const DumpBottle & operator=(const DumpBottle &obj)
Definition main.cpp:69
const std::string toFile(const std::string &dirName, unsigned int cnt) override
Definition main.cpp:72
DumpImage()
Definition main.cpp:100
~DumpImage()
Definition main.cpp:104
DumpImage(const DumpImage &obj)
Definition main.cpp:101
DumpImage(const Image &img)
Definition main.cpp:102
const std::string toFile(const std::string &dirName, unsigned int cnt) override
Definition main.cpp:106
const DumpImage & operator=(const DumpImage &obj)
Definition main.cpp:103
bool close() override
Close function.
Definition main.cpp:801
bool updateModule() override
Override this to do whatever your module needs to do.
Definition main.cpp:828
bool configure(ResourceFinder &rf) override
Configure the module, pass a ResourceFinder object to the module.
Definition main.cpp:641
DumpModule()=default
double getPeriod() override
You can override this to control the approximate periodicity at which updateModule() is called by run...
Definition main.cpp:827
virtual ~DumpObj()=default
virtual void attachFormat(const DumpFormat &format)
Definition main.cpp:54
virtual const std::string toFile(const std::string &, unsigned int)=0
DumpFormat m_dump_format
Definition main.cpp:49
DumpPort(DumpQueue &Q, unsigned int _dwnsample=1, bool _rxTime=true, bool _txTime=false, DumpFormat _dataformat=DumpFormat::bottle)
Definition main.cpp:275
void unlock()
Definition main.cpp:266
void lock()
Definition main.cpp:265
DumpReporter()=default
void setThread(DumpThread *thread)
Definition main.cpp:594
void report(const PortInfo &info) override
Callback for port event/state information.
Definition main.cpp:595
DumpThread(DumpFormat _type, DumpQueue &Q, const std::string &_dirName, const int szToWrite, const bool _saveData, const bool _videoOn, const std::string &_videoType, const bool _rxTime, const bool _txTime)
Definition main.cpp:367
void writeSource(const std::string &sourceName, const bool connected)
Definition main.cpp:413
bool threadInit() override
Initialization method.
Definition main.cpp:420
void run() override
Loop function.
Definition main.cpp:486
void threadRelease() override
Release method.
Definition main.cpp:568
std::string getString() const
Definition main.cpp:224
DumpTimeStamp()=default
void setTxStamp(const double stamp)
Definition main.cpp:213
double getStamp() const
Definition main.cpp:214
void setRxStamp(const double stamp)
Definition main.cpp:212
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:64
std::string toString() const override
Gives a human-readable textual representation of the bottle.
Definition Bottle.cpp:211
A mini-server for performing network communication in the background.
std::string getName() const override
Get name of port.
bool getEnvelope(PortReader &envelope) override
Get the envelope information (e.g., a timestamp) from the last message received on the 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 interrupt() override
Interrupt any current reads or writes attached to the port.
void setReporter(PortReport &reporter) override
Set a callback to be called upon any future connections and disconnections to/from the port.
void useCallback(TypedReaderCallback< T > &callback) override
Set an object whose onRead method will be called when data is available.
void setStrict(bool strict=true) override
Call this to strictly keep all messages, or allow old ones to be quietly dropped.
Utilities for manipulating the YARP network, including initialization and shutdown.
Definition Network.h:706
An abstraction for a periodic thread.
bool start()
Call this to start the thread.
void stop()
Call this to stop the thread, this call blocks until the thread is terminated (and releaseThread() ca...
Information about a port connection or event.
Definition PortInfo.h:25
A base class for objects that want information about port status changes.
Definition PortReport.h:25
A mini-server for network communication.
Definition Port.h:46
void interrupt() override
Interrupt any current reads or writes attached to the port.
Definition Port.cpp:383
void close() override
Stop port activity.
Definition Port.cpp:363
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
Definition Port.cpp:79
A base-class for standard YARP modules that supports ResourceFinder.
Definition RFModule.h:20
virtual bool attach(yarp::os::Port &source)
Make any input from a Port object go to the respond() method.
Definition RFModule.cpp:456
Helper class for finding config files and other external resources.
bool check(const std::string &key) const override
Check if there exists a property of the given name.
bool configure(int argc, char *argv[], bool skipFirstArgument=true)
Sets up the ResourceFinder.
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
An abstraction for a time stamp and/or sequence number.
Definition Stamp.h:21
A single value (typically within a Bottle).
Definition Value.h:43
virtual std::string asString() const
Get string value.
Definition Value.cpp:234
Base class for storing images.
Definition Image.h:79
virtual int getPixelCode() const
Gets pixel type identifier.
Definition Image.cpp:390
int main(int argc, char *argv[])
Definition main.cpp:833
DumpObj * factory(Bottle &obj)
Definition main.cpp:82
DumpFormat
Definition main.cpp:42
STL namespace.
::cv::Mat toCvMat(yarp::sig::Image &yarpImage)
Convert a yarp::sig::FlexImage to a cv::Mat object.
Definition Cv-inl.h:84
double now()
Return the current time in seconds, relative to an arbitrary starting point.
Definition Time.cpp:121
std::string decode(NetInt32 code)
Convert a vocabulary identifier into a string.
Definition Vocab.cpp:33
An interface to the operating system, including Port based communication.
int stat(const char *path)
Portable wrapper for the stat() function.
Definition Os.cpp:78
int mkdir_p(const char *p, int ignoreLevels=0)
Create a directory and all parent directories needed.
Definition Os.cpp:35
@ FORMAT_NUMERIC_COMPRESSED
Definition ImageFile.h:22
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
The main, catch-all namespace for YARP.
Definition dirs.h:16
DumpObj * obj
Definition main.cpp:250
DumpTimeStamp timeStamp
Definition main.cpp:249
int seqNumber
Definition main.cpp:248