gusimplewhiteboard
VisionControlStatus.hpp
Go to the documentation of this file.
1/*
2 * file VisionControlStatus.hpp
3 *
4 * This file was generated by classgenerator from vision_control_status.gen.
5 * DO NOT CHANGE MANUALLY!
6 *
7 * Copyright © 2021 Eugene Gilmore. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer in the documentation and/or other materials
19 * provided with the distribution.
20 *
21 * 3. All advertising materials mentioning features or use of this
22 * software must display the following acknowledgement:
23 *
24 * This product includes software developed by Eugene Gilmore.
25 *
26 * 4. Neither the name of the author nor the names of contributors
27 * may be used to endorse or promote products derived from this
28 * software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
34 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
35 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
37 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
38 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
39 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
40 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 *
42 * -----------------------------------------------------------------------
43 * This program is free software; you can redistribute it and/or
44 * modify it under the above terms or under the terms of the GNU
45 * General Public License as published by the Free Software Foundation;
46 * either version 2 of the License, or (at your option) any later version.
47 *
48 * This program is distributed in the hope that it will be useful,
49 * but WITHOUT ANY WARRANTY; without even the implied warranty of
50 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
51 * GNU General Public License for more details.
52 *
53 * You should have received a copy of the GNU General Public License
54 * along with this program; if not, see http://www.gnu.org/licenses/
55 * or write to the Free Software Foundation, Inc., 51 Franklin Street,
56 * Fifth Floor, Boston, MA 02110-1301, USA.
57 *
58 */
59
60#ifndef guWhiteboard_VisionControlStatus_h
61#define guWhiteboard_VisionControlStatus_h
62
63#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
64#include <cstdlib>
65#include <string.h>
66#include <sstream>
67#endif
68
69#include <gu_util.h>
71#include <float.h>
72
73#undef guWhiteboard_VisionControlStatus_DEFINED
74#define guWhiteboard_VisionControlStatus_DEFINED
75
76#undef VisionControlStatus_DEFINED
77#define VisionControlStatus_DEFINED
78
79namespace guWhiteboard {
80
85
86 private:
87
91 void init(enum Resolutions t_cameraResolution = VGA, bool t_pipelineRunning = true, enum VisionCamera t_selectedCamera = Top, enum SaveFileType t_saveImage = None, bool t_saveClassifiedImage = false, enum NamedPipeline t_pipeline = Soccer, int t_chooseCamera = 0, float t_confidence = 0.8f, enum NeuralNetworkType t_networkTop = v2, enum NeuralNetworkType t_networkBottom = v2, enum StreamingType t_streamingSource = Normal, bool t_imageInput = false, int t_jpegStreamQuality = 30, int t_jpegStreamStride = 4, int t_frameRate = 0, bool t_runPipelineOnce = false, uint64_t t_frameNumber = 0, std::string t_colourCalibration = "class", struct timeval t_imageTime = {}) {
92 set_cameraResolution(t_cameraResolution);
93 set_pipelineRunning(t_pipelineRunning);
94 set_selectedCamera(t_selectedCamera);
95 set_saveImage(t_saveImage);
96 set_saveClassifiedImage(t_saveClassifiedImage);
97 set_pipeline(t_pipeline);
98 set_chooseCamera(t_chooseCamera);
99 set_confidence(t_confidence);
100 set_networkTop(t_networkTop);
101 set_networkBottom(t_networkBottom);
102 set_streamingSource(t_streamingSource);
103 set_imageInput(t_imageInput);
104 set_jpegStreamQuality(t_jpegStreamQuality);
105 set_jpegStreamStride(t_jpegStreamStride);
106 set_frameRate(t_frameRate);
107 set_runPipelineOnce(t_runPipelineOnce);
108 set_frameNumber(t_frameNumber);
109 gu_strlcpy(const_cast<char *>(this->colourCalibration()), t_colourCalibration.c_str(), 10);
110 set_imageTime(t_imageTime);
111 }
112
113 public:
114
118 VisionControlStatus(enum Resolutions t_cameraResolution = VGA, bool t_pipelineRunning = true, enum VisionCamera t_selectedCamera = Top, enum SaveFileType t_saveImage = None, bool t_saveClassifiedImage = false, enum NamedPipeline t_pipeline = Soccer, int t_chooseCamera = 0, float t_confidence = 0.8f, enum NeuralNetworkType t_networkTop = v2, enum NeuralNetworkType t_networkBottom = v2, enum StreamingType t_streamingSource = Normal, bool t_imageInput = false, int t_jpegStreamQuality = 30, int t_jpegStreamStride = 4, int t_frameRate = 0, bool t_runPipelineOnce = false, uint64_t t_frameNumber = 0, std::string t_colourCalibration = "class", struct timeval t_imageTime = {}) {
119 this->init(t_cameraResolution, t_pipelineRunning, t_selectedCamera, t_saveImage, t_saveClassifiedImage, t_pipeline, t_chooseCamera, t_confidence, t_networkTop, t_networkBottom, t_streamingSource, t_imageInput, t_jpegStreamQuality, t_jpegStreamStride, t_frameRate, t_runPipelineOnce, t_frameNumber, t_colourCalibration, t_imageTime);
120 }
121
126 this->init(t_other.cameraResolution(), t_other.pipelineRunning(), t_other.selectedCamera(), t_other.saveImage(), t_other.saveClassifiedImage(), t_other.pipeline(), t_other.chooseCamera(), t_other.confidence(), t_other.networkTop(), t_other.networkBottom(), t_other.streamingSource(), t_other.imageInput(), t_other.jpegStreamQuality(), t_other.jpegStreamStride(), t_other.frameRate(), t_other.runPipelineOnce(), t_other.frameNumber(), t_other.colourCalibration(), t_other.imageTime());
127 }
128
133 this->init(t_other.cameraResolution, t_other.pipelineRunning, t_other.selectedCamera, t_other.saveImage, t_other.saveClassifiedImage, t_other.pipeline, t_other.chooseCamera, t_other.confidence, t_other.networkTop, t_other.networkBottom, t_other.streamingSource, t_other.imageInput, t_other.jpegStreamQuality, t_other.jpegStreamStride, t_other.frameRate, t_other.runPipelineOnce, t_other.frameNumber, t_other.colourCalibration, t_other.imageTime);
134 }
135
140 this->init(t_other.cameraResolution(), t_other.pipelineRunning(), t_other.selectedCamera(), t_other.saveImage(), t_other.saveClassifiedImage(), t_other.pipeline(), t_other.chooseCamera(), t_other.confidence(), t_other.networkTop(), t_other.networkBottom(), t_other.streamingSource(), t_other.imageInput(), t_other.jpegStreamQuality(), t_other.jpegStreamStride(), t_other.frameRate(), t_other.runPipelineOnce(), t_other.frameNumber(), t_other.colourCalibration(), t_other.imageTime());
141 return *this;
142 }
143
148 this->init(t_other.cameraResolution, t_other.pipelineRunning, t_other.selectedCamera, t_other.saveImage, t_other.saveClassifiedImage, t_other.pipeline, t_other.chooseCamera, t_other.confidence, t_other.networkTop, t_other.networkBottom, t_other.streamingSource, t_other.imageInput, t_other.jpegStreamQuality, t_other.jpegStreamStride, t_other.frameRate, t_other.runPipelineOnce, t_other.frameNumber, t_other.colourCalibration, t_other.imageTime);
149 return *this;
150 }
151
152 bool operator ==(const VisionControlStatus &t_other) const
153 {
154 return cameraResolution() == t_other.cameraResolution()
155 && pipelineRunning() == t_other.pipelineRunning()
156 && selectedCamera() == t_other.selectedCamera()
157 && saveImage() == t_other.saveImage()
159 && pipeline() == t_other.pipeline()
160 && chooseCamera() == t_other.chooseCamera()
161 && fabsf(confidence() - t_other.confidence()) < FLT_EPSILON
162 && networkTop() == t_other.networkTop()
163 && networkBottom() == t_other.networkBottom()
164 && streamingSource() == t_other.streamingSource()
165 && imageInput() == t_other.imageInput()
166 && jpegStreamQuality() == t_other.jpegStreamQuality()
167 && jpegStreamStride() == t_other.jpegStreamStride()
168 && frameRate() == t_other.frameRate()
169 && runPipelineOnce() == t_other.runPipelineOnce()
170 && frameNumber() == t_other.frameNumber()
171 && 0 == strncmp(colourCalibration(), t_other.colourCalibration(), 10);
172 }
173
174 bool operator !=(const VisionControlStatus &t_other) const
175 {
176 return !(*this == t_other);
177 }
178
179 bool operator ==(const wb_vision_control_status &t_other) const
180 {
181 return *this == VisionControlStatus(t_other);
182 }
183
184 bool operator !=(const wb_vision_control_status &t_other) const
185 {
186 return !(*this == t_other);
187 }
188
190 {
192 }
193
194 const enum Resolutions & cameraResolution() const
195 {
197 }
198
199 void set_cameraResolution(const enum Resolutions &t_newValue)
200 {
202 }
203
205 {
207 }
208
209 const bool & pipelineRunning() const
210 {
212 }
213
214 void set_pipelineRunning(const bool &t_newValue)
215 {
217 }
218
220 {
222 }
223
224 const enum VisionCamera & selectedCamera() const
225 {
227 }
228
229 void set_selectedCamera(const enum VisionCamera &t_newValue)
230 {
232 }
233
235 {
237 }
238
239 const enum SaveFileType & saveImage() const
240 {
242 }
243
244 void set_saveImage(const enum SaveFileType &t_newValue)
245 {
247 }
248
250 {
252 }
253
254 const bool & saveClassifiedImage() const
255 {
257 }
258
259 void set_saveClassifiedImage(const bool &t_newValue)
260 {
262 }
263
265 {
267 }
268
269 const enum NamedPipeline & pipeline() const
270 {
272 }
273
274 void set_pipeline(const enum NamedPipeline &t_newValue)
275 {
277 }
278
280 {
282 }
283
284 const int & chooseCamera() const
285 {
287 }
288
289 void set_chooseCamera(const int &t_newValue)
290 {
292 }
293
294 float & confidence()
295 {
297 }
298
299 const float & confidence() const
300 {
302 }
303
304 void set_confidence(const float &t_newValue)
305 {
307 }
308
310 {
312 }
313
314 const enum NeuralNetworkType & networkTop() const
315 {
317 }
318
319 void set_networkTop(const enum NeuralNetworkType &t_newValue)
320 {
322 }
323
325 {
327 }
328
329 const enum NeuralNetworkType & networkBottom() const
330 {
332 }
333
334 void set_networkBottom(const enum NeuralNetworkType &t_newValue)
335 {
337 }
338
340 {
342 }
343
344 const enum StreamingType & streamingSource() const
345 {
347 }
348
349 void set_streamingSource(const enum StreamingType &t_newValue)
350 {
352 }
353
354 bool & imageInput()
355 {
357 }
358
359 const bool & imageInput() const
360 {
362 }
363
364 void set_imageInput(const bool &t_newValue)
365 {
367 }
368
370 {
372 }
373
374 const int & jpegStreamQuality() const
375 {
377 }
378
379 void set_jpegStreamQuality(const int &t_newValue)
380 {
382 }
383
385 {
387 }
388
389 const int & jpegStreamStride() const
390 {
392 }
393
394 void set_jpegStreamStride(const int &t_newValue)
395 {
397 }
398
399 int & frameRate()
400 {
402 }
403
404 const int & frameRate() const
405 {
407 }
408
409 void set_frameRate(const int &t_newValue)
410 {
412 }
413
415 {
417 }
418
419 const bool & runPipelineOnce() const
420 {
422 }
423
424 void set_runPipelineOnce(const bool &t_newValue)
425 {
427 }
428
429 uint64_t & frameNumber()
430 {
432 }
433
434 const uint64_t & frameNumber() const
435 {
437 }
438
439 void set_frameNumber(const uint64_t &t_newValue)
440 {
442 }
443
444 const char * colourCalibration() const
445 {
447 }
448
450 {
451 return 10;
452 }
453
454 char & colourCalibration(int t_i)
455 {
457 }
458
459 const char & colourCalibration(int t_i) const
460 {
462 }
463
464 void set_colourCalibration(const char *t_newValue)
465 {
466 strncpy(wb_vision_control_status::colourCalibration, t_newValue, 10);
467 }
468
469 struct timeval & imageTime()
470 {
472 }
473
474 const struct timeval & imageTime() const
475 {
477 }
478
479 void set_imageTime(const struct timeval &t_newValue)
480 {
482 }
483
484#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
488 VisionControlStatus(const std::string &t_str) {
489 this->init();
490 this->from_string(t_str);
491 }
492
493 std::string description() {
494#ifdef USE_WB_VISION_CONTROL_STATUS_C_CONVERSION
496 wb_vision_control_status_description(this, buffer, sizeof(buffer));
497 std::string descr = buffer;
498 return descr;
499#else
500 std::ostringstream ss;
501 switch (this->cameraResolution()) {
502 case HD_4VGA:
503 {
504 ss << "cameraResolution=" << "HD_4VGA";
505 break;
506 }
507 case QQVGA:
508 {
509 ss << "cameraResolution=" << "QQVGA";
510 break;
511 }
512 case QVGA:
513 {
514 ss << "cameraResolution=" << "QVGA";
515 break;
516 }
517 case SVGA:
518 {
519 ss << "cameraResolution=" << "SVGA";
520 break;
521 }
522 case VGA:
523 {
524 ss << "cameraResolution=" << "VGA";
525 break;
526 }
527 }
528 ss << ", ";
529 ss << "pipelineRunning=" << (this->pipelineRunning() ? "true" : "false");
530 ss << ", ";
531 switch (this->selectedCamera()) {
532 case Bottom:
533 {
534 ss << "selectedCamera=" << "Bottom";
535 break;
536 }
538 {
539 ss << "selectedCamera=" << "NUM_VISION_CAMERAS";
540 break;
541 }
542 case Top:
543 {
544 ss << "selectedCamera=" << "Top";
545 break;
546 }
547 }
548 ss << ", ";
549 switch (this->saveImage()) {
550 case AI2:
551 {
552 ss << "saveImage=" << "AI2";
553 break;
554 }
555 case AI3:
556 {
557 ss << "saveImage=" << "AI3";
558 break;
559 }
560 case JPG:
561 {
562 ss << "saveImage=" << "JPG";
563 break;
564 }
565 case None:
566 {
567 ss << "saveImage=" << "None";
568 break;
569 }
570 }
571 ss << ", ";
572 ss << "saveClassifiedImage=" << (this->saveClassifiedImage() ? "true" : "false");
573 ss << ", ";
574 switch (this->pipeline()) {
575 case HTWK:
576 {
577 ss << "pipeline=" << "HTWK";
578 break;
579 }
580 case Neural_Network:
581 {
582 ss << "pipeline=" << "Neural_Network";
583 break;
584 }
585 case OpenCVFaces:
586 {
587 ss << "pipeline=" << "OpenCVFaces";
588 break;
589 }
590 case OpenChallenge:
591 {
592 ss << "pipeline=" << "OpenChallenge";
593 break;
594 }
595 case Soccer:
596 {
597 ss << "pipeline=" << "Soccer";
598 break;
599 }
600 case Streaming:
601 {
602 ss << "pipeline=" << "Streaming";
603 break;
604 }
605 }
606 ss << ", ";
607 ss << "chooseCamera=" << static_cast<signed>(this->chooseCamera());
608 ss << ", ";
609 ss << "confidence=" << this->confidence();
610 ss << ", ";
611 switch (this->networkTop()) {
612 case BallOnly:
613 {
614 ss << "networkTop=" << "BallOnly";
615 break;
616 }
617 case VGANet:
618 {
619 ss << "networkTop=" << "VGANet";
620 break;
621 }
622 case Vanilla:
623 {
624 ss << "networkTop=" << "Vanilla";
625 break;
626 }
627 case v2:
628 {
629 ss << "networkTop=" << "v2";
630 break;
631 }
632 }
633 ss << ", ";
634 switch (this->networkBottom()) {
635 case BallOnly:
636 {
637 ss << "networkBottom=" << "BallOnly";
638 break;
639 }
640 case VGANet:
641 {
642 ss << "networkBottom=" << "VGANet";
643 break;
644 }
645 case Vanilla:
646 {
647 ss << "networkBottom=" << "Vanilla";
648 break;
649 }
650 case v2:
651 {
652 ss << "networkBottom=" << "v2";
653 break;
654 }
655 }
656 ss << ", ";
657 switch (this->streamingSource()) {
658 case Classified:
659 {
660 ss << "streamingSource=" << "Classified";
661 break;
662 }
663 case Normal:
664 {
665 ss << "streamingSource=" << "Normal";
666 break;
667 }
668 case Recognized:
669 {
670 ss << "streamingSource=" << "Recognized";
671 break;
672 }
673 }
674 ss << ", ";
675 ss << "imageInput=" << (this->imageInput() ? "true" : "false");
676 ss << ", ";
677 ss << "jpegStreamQuality=" << static_cast<signed>(this->jpegStreamQuality());
678 ss << ", ";
679 ss << "jpegStreamStride=" << static_cast<signed>(this->jpegStreamStride());
680 ss << ", ";
681 ss << "frameRate=" << static_cast<signed>(this->frameRate());
682 ss << ", ";
683 ss << "runPipelineOnce=" << (this->runPipelineOnce() ? "true" : "false");
684 ss << ", ";
685 ss << "frameNumber=" << this->frameNumber();
686 ss << ", ";
687 if (0 == strncmp("", this->colourCalibration(), 1)) {
688 ss << "colourCalibration=" << "";
689 } else {
690 ss << "colourCalibration=" << this->colourCalibration();
691 }
692 return ss.str();
693#endif
694 }
695
696 std::string to_string() {
697#ifdef USE_WB_VISION_CONTROL_STATUS_C_CONVERSION
699 wb_vision_control_status_to_string(this, buffer, sizeof(buffer));
700 std::string toString = buffer;
701 return toString;
702#else
703 std::ostringstream ss;
704 switch (this->cameraResolution()) {
705 case HD_4VGA:
706 {
707 ss << "HD_4VGA";
708 break;
709 }
710 case QQVGA:
711 {
712 ss << "QQVGA";
713 break;
714 }
715 case QVGA:
716 {
717 ss << "QVGA";
718 break;
719 }
720 case SVGA:
721 {
722 ss << "SVGA";
723 break;
724 }
725 case VGA:
726 {
727 ss << "VGA";
728 break;
729 }
730 }
731 ss << ", ";
732 ss << (this->pipelineRunning() ? "true" : "false");
733 ss << ", ";
734 switch (this->selectedCamera()) {
735 case Bottom:
736 {
737 ss << "Bottom";
738 break;
739 }
741 {
742 ss << "NUM_VISION_CAMERAS";
743 break;
744 }
745 case Top:
746 {
747 ss << "Top";
748 break;
749 }
750 }
751 ss << ", ";
752 switch (this->saveImage()) {
753 case AI2:
754 {
755 ss << "AI2";
756 break;
757 }
758 case AI3:
759 {
760 ss << "AI3";
761 break;
762 }
763 case JPG:
764 {
765 ss << "JPG";
766 break;
767 }
768 case None:
769 {
770 ss << "None";
771 break;
772 }
773 }
774 ss << ", ";
775 ss << (this->saveClassifiedImage() ? "true" : "false");
776 ss << ", ";
777 switch (this->pipeline()) {
778 case HTWK:
779 {
780 ss << "HTWK";
781 break;
782 }
783 case Neural_Network:
784 {
785 ss << "Neural_Network";
786 break;
787 }
788 case OpenCVFaces:
789 {
790 ss << "OpenCVFaces";
791 break;
792 }
793 case OpenChallenge:
794 {
795 ss << "OpenChallenge";
796 break;
797 }
798 case Soccer:
799 {
800 ss << "Soccer";
801 break;
802 }
803 case Streaming:
804 {
805 ss << "Streaming";
806 break;
807 }
808 }
809 ss << ", ";
810 ss << static_cast<signed>(this->chooseCamera());
811 ss << ", ";
812 ss << this->confidence();
813 ss << ", ";
814 switch (this->networkTop()) {
815 case BallOnly:
816 {
817 ss << "BallOnly";
818 break;
819 }
820 case VGANet:
821 {
822 ss << "VGANet";
823 break;
824 }
825 case Vanilla:
826 {
827 ss << "Vanilla";
828 break;
829 }
830 case v2:
831 {
832 ss << "v2";
833 break;
834 }
835 }
836 ss << ", ";
837 switch (this->networkBottom()) {
838 case BallOnly:
839 {
840 ss << "BallOnly";
841 break;
842 }
843 case VGANet:
844 {
845 ss << "VGANet";
846 break;
847 }
848 case Vanilla:
849 {
850 ss << "Vanilla";
851 break;
852 }
853 case v2:
854 {
855 ss << "v2";
856 break;
857 }
858 }
859 ss << ", ";
860 switch (this->streamingSource()) {
861 case Classified:
862 {
863 ss << "Classified";
864 break;
865 }
866 case Normal:
867 {
868 ss << "Normal";
869 break;
870 }
871 case Recognized:
872 {
873 ss << "Recognized";
874 break;
875 }
876 }
877 ss << ", ";
878 ss << (this->imageInput() ? "true" : "false");
879 ss << ", ";
880 ss << static_cast<signed>(this->jpegStreamQuality());
881 ss << ", ";
882 ss << static_cast<signed>(this->jpegStreamStride());
883 ss << ", ";
884 ss << static_cast<signed>(this->frameRate());
885 ss << ", ";
886 ss << (this->runPipelineOnce() ? "true" : "false");
887 ss << ", ";
888 ss << this->frameNumber();
889 ss << ", ";
890 if (0 == strncmp("", this->colourCalibration(), 1)) {
891 ss << "";
892 } else {
893 ss << this->colourCalibration();
894 }
895 return ss.str();
896#endif
897 }
898
899#ifdef USE_WB_VISION_CONTROL_STATUS_C_CONVERSION
900 void from_string(const std::string &t_str) {
901 wb_vision_control_status_from_string(this, t_str.c_str());
902#else
903 void from_string(const std::string &t_str) {
904 char * str_cstr = const_cast<char *>(t_str.c_str());
905 size_t temp_length = strlen(str_cstr);
906 int length = (temp_length <= INT_MAX) ? static_cast<int>(static_cast<ssize_t>(temp_length)) : -1;
907 if (length < 1 || length > VISION_CONTROL_STATUS_DESC_BUFFER_SIZE) {
908 return;
909 }
910 char var_str_buffer[VISION_CONTROL_STATUS_DESC_BUFFER_SIZE + 1];
911 char* var_str = &var_str_buffer[0];
912 char key_buffer[20];
913 char* key = &key_buffer[0];
914 int bracecount = 0;
915 int startVar = 0;
916 int index = 0;
917 int startKey = 0;
918 int endKey = -1;
919 int varIndex = 0;
920 if (index == 0 && str_cstr[0] == '{') {
921 index = 1;
922 }
923 startVar = index;
924 startKey = startVar;
925 do {
926 for (int i = index; i < length; i++) {
927 index = i + 1;
928 if (bracecount == 0 && str_cstr[i] == '=') {
929 endKey = i - 1;
930 startVar = index;
931 continue;
932 }
933 if (bracecount == 0 && isspace(str_cstr[i])) {
934 startVar = index;
935 if (endKey == -1) {
936 startKey = index;
937 }
938 continue;
939 }
940 if (bracecount == 0 && str_cstr[i] == ',') {
941 index = i - 1;
942 break;
943 }
944 if (str_cstr[i] == '{') {
945 bracecount++;
946 continue;
947 }
948 if (str_cstr[i] == '}') {
949 bracecount--;
950 if (bracecount < 0) {
951 index = i - 1;
952 break;
953 }
954 }
955 if (i == length - 1) {
956 index = i;
957 }
958 }
959 if (endKey >= startKey && endKey - startKey < length) {
960 strncpy(key, str_cstr + startKey, static_cast<size_t>((endKey - startKey) + 1));
961 key[(endKey - startKey) + 1] = 0;
962 } else {
963 key[0] = 0;
964 }
965 strncpy(var_str, str_cstr + startVar, static_cast<size_t>((index - startVar) + 1));
966 var_str[(index - startVar) + 1] = 0;
967 bracecount = 0;
968 index += 2;
969 startVar = index;
970 startKey = startVar;
971 endKey = -1;
972 if (strlen(key) > 0) {
973 if (0 == strcmp("cameraResolution", key)) {
974 varIndex = 0;
975 } else if (0 == strcmp("pipelineRunning", key)) {
976 varIndex = 1;
977 } else if (0 == strcmp("selectedCamera", key)) {
978 varIndex = 2;
979 } else if (0 == strcmp("saveImage", key)) {
980 varIndex = 3;
981 } else if (0 == strcmp("saveClassifiedImage", key)) {
982 varIndex = 4;
983 } else if (0 == strcmp("pipeline", key)) {
984 varIndex = 5;
985 } else if (0 == strcmp("chooseCamera", key)) {
986 varIndex = 6;
987 } else if (0 == strcmp("confidence", key)) {
988 varIndex = 7;
989 } else if (0 == strcmp("networkTop", key)) {
990 varIndex = 8;
991 } else if (0 == strcmp("networkBottom", key)) {
992 varIndex = 9;
993 } else if (0 == strcmp("streamingSource", key)) {
994 varIndex = 10;
995 } else if (0 == strcmp("imageInput", key)) {
996 varIndex = 11;
997 } else if (0 == strcmp("jpegStreamQuality", key)) {
998 varIndex = 12;
999 } else if (0 == strcmp("jpegStreamStride", key)) {
1000 varIndex = 13;
1001 } else if (0 == strcmp("frameRate", key)) {
1002 varIndex = 14;
1003 } else if (0 == strcmp("runPipelineOnce", key)) {
1004 varIndex = 15;
1005 } else if (0 == strcmp("frameNumber", key)) {
1006 varIndex = 16;
1007 } else if (0 == strcmp("colourCalibration", key)) {
1008 varIndex = 17;
1009 } else {
1010 varIndex = -1;
1011 }
1012 }
1013 switch (varIndex) {
1014 case -1: { break; }
1015 case 0:
1016 {
1017 if (strcmp("HD_4VGA", var_str) == 0) {
1018#pragma clang diagnostic push
1019#pragma clang diagnostic ignored "-Wbad-function-cast"
1021#pragma clang diagnostic pop
1022 } else if (strcmp("QQVGA", var_str) == 0) {
1023#pragma clang diagnostic push
1024#pragma clang diagnostic ignored "-Wbad-function-cast"
1026#pragma clang diagnostic pop
1027 } else if (strcmp("QVGA", var_str) == 0) {
1028#pragma clang diagnostic push
1029#pragma clang diagnostic ignored "-Wbad-function-cast"
1031#pragma clang diagnostic pop
1032 } else if (strcmp("SVGA", var_str) == 0) {
1033#pragma clang diagnostic push
1034#pragma clang diagnostic ignored "-Wbad-function-cast"
1036#pragma clang diagnostic pop
1037 } else if (strcmp("VGA", var_str) == 0) {
1038#pragma clang diagnostic push
1039#pragma clang diagnostic ignored "-Wbad-function-cast"
1041#pragma clang diagnostic pop
1042 } else {
1043#pragma clang diagnostic push
1044#pragma clang diagnostic ignored "-Wbad-function-cast"
1045 this->set_cameraResolution(static_cast<enum Resolutions>(atoi(var_str)));
1046#pragma clang diagnostic pop
1047 }
1048 break;
1049 }
1050 case 1:
1051 {
1052 this->set_pipelineRunning(strcmp(var_str, "true") == 0 || strcmp(var_str, "1") == 0);
1053 break;
1054 }
1055 case 2:
1056 {
1057 if (strcmp("Bottom", var_str) == 0) {
1058#pragma clang diagnostic push
1059#pragma clang diagnostic ignored "-Wbad-function-cast"
1061#pragma clang diagnostic pop
1062 } else if (strcmp("NUM_VISION_CAMERAS", var_str) == 0) {
1063#pragma clang diagnostic push
1064#pragma clang diagnostic ignored "-Wbad-function-cast"
1066#pragma clang diagnostic pop
1067 } else if (strcmp("Top", var_str) == 0) {
1068#pragma clang diagnostic push
1069#pragma clang diagnostic ignored "-Wbad-function-cast"
1070 this->set_selectedCamera(Top);
1071#pragma clang diagnostic pop
1072 } else {
1073#pragma clang diagnostic push
1074#pragma clang diagnostic ignored "-Wbad-function-cast"
1075 this->set_selectedCamera(static_cast<enum VisionCamera>(atoi(var_str)));
1076#pragma clang diagnostic pop
1077 }
1078 break;
1079 }
1080 case 3:
1081 {
1082 if (strcmp("AI2", var_str) == 0) {
1083#pragma clang diagnostic push
1084#pragma clang diagnostic ignored "-Wbad-function-cast"
1085 this->set_saveImage(AI2);
1086#pragma clang diagnostic pop
1087 } else if (strcmp("AI3", var_str) == 0) {
1088#pragma clang diagnostic push
1089#pragma clang diagnostic ignored "-Wbad-function-cast"
1090 this->set_saveImage(AI3);
1091#pragma clang diagnostic pop
1092 } else if (strcmp("JPG", var_str) == 0) {
1093#pragma clang diagnostic push
1094#pragma clang diagnostic ignored "-Wbad-function-cast"
1095 this->set_saveImage(JPG);
1096#pragma clang diagnostic pop
1097 } else if (strcmp("None", var_str) == 0) {
1098#pragma clang diagnostic push
1099#pragma clang diagnostic ignored "-Wbad-function-cast"
1100 this->set_saveImage(None);
1101#pragma clang diagnostic pop
1102 } else {
1103#pragma clang diagnostic push
1104#pragma clang diagnostic ignored "-Wbad-function-cast"
1105 this->set_saveImage(static_cast<enum SaveFileType>(atoi(var_str)));
1106#pragma clang diagnostic pop
1107 }
1108 break;
1109 }
1110 case 4:
1111 {
1112 this->set_saveClassifiedImage(strcmp(var_str, "true") == 0 || strcmp(var_str, "1") == 0);
1113 break;
1114 }
1115 case 5:
1116 {
1117 if (strcmp("HTWK", var_str) == 0) {
1118#pragma clang diagnostic push
1119#pragma clang diagnostic ignored "-Wbad-function-cast"
1120 this->set_pipeline(HTWK);
1121#pragma clang diagnostic pop
1122 } else if (strcmp("Neural_Network", var_str) == 0) {
1123#pragma clang diagnostic push
1124#pragma clang diagnostic ignored "-Wbad-function-cast"
1126#pragma clang diagnostic pop
1127 } else if (strcmp("OpenCVFaces", var_str) == 0) {
1128#pragma clang diagnostic push
1129#pragma clang diagnostic ignored "-Wbad-function-cast"
1131#pragma clang diagnostic pop
1132 } else if (strcmp("OpenChallenge", var_str) == 0) {
1133#pragma clang diagnostic push
1134#pragma clang diagnostic ignored "-Wbad-function-cast"
1136#pragma clang diagnostic pop
1137 } else if (strcmp("Soccer", var_str) == 0) {
1138#pragma clang diagnostic push
1139#pragma clang diagnostic ignored "-Wbad-function-cast"
1140 this->set_pipeline(Soccer);
1141#pragma clang diagnostic pop
1142 } else if (strcmp("Streaming", var_str) == 0) {
1143#pragma clang diagnostic push
1144#pragma clang diagnostic ignored "-Wbad-function-cast"
1145 this->set_pipeline(Streaming);
1146#pragma clang diagnostic pop
1147 } else {
1148#pragma clang diagnostic push
1149#pragma clang diagnostic ignored "-Wbad-function-cast"
1150 this->set_pipeline(static_cast<enum NamedPipeline>(atoi(var_str)));
1151#pragma clang diagnostic pop
1152 }
1153 break;
1154 }
1155 case 6:
1156 {
1157 this->set_chooseCamera(static_cast<int>(atoi(var_str)));
1158 break;
1159 }
1160 case 7:
1161 {
1162 this->set_confidence(static_cast<float>(atof(var_str)));
1163 break;
1164 }
1165 case 8:
1166 {
1167 if (strcmp("BallOnly", var_str) == 0) {
1168#pragma clang diagnostic push
1169#pragma clang diagnostic ignored "-Wbad-function-cast"
1170 this->set_networkTop(BallOnly);
1171#pragma clang diagnostic pop
1172 } else if (strcmp("VGANet", var_str) == 0) {
1173#pragma clang diagnostic push
1174#pragma clang diagnostic ignored "-Wbad-function-cast"
1175 this->set_networkTop(VGANet);
1176#pragma clang diagnostic pop
1177 } else if (strcmp("Vanilla", var_str) == 0) {
1178#pragma clang diagnostic push
1179#pragma clang diagnostic ignored "-Wbad-function-cast"
1180 this->set_networkTop(Vanilla);
1181#pragma clang diagnostic pop
1182 } else if (strcmp("v2", var_str) == 0) {
1183#pragma clang diagnostic push
1184#pragma clang diagnostic ignored "-Wbad-function-cast"
1185 this->set_networkTop(v2);
1186#pragma clang diagnostic pop
1187 } else {
1188#pragma clang diagnostic push
1189#pragma clang diagnostic ignored "-Wbad-function-cast"
1190 this->set_networkTop(static_cast<enum NeuralNetworkType>(atoi(var_str)));
1191#pragma clang diagnostic pop
1192 }
1193 break;
1194 }
1195 case 9:
1196 {
1197 if (strcmp("BallOnly", var_str) == 0) {
1198#pragma clang diagnostic push
1199#pragma clang diagnostic ignored "-Wbad-function-cast"
1201#pragma clang diagnostic pop
1202 } else if (strcmp("VGANet", var_str) == 0) {
1203#pragma clang diagnostic push
1204#pragma clang diagnostic ignored "-Wbad-function-cast"
1206#pragma clang diagnostic pop
1207 } else if (strcmp("Vanilla", var_str) == 0) {
1208#pragma clang diagnostic push
1209#pragma clang diagnostic ignored "-Wbad-function-cast"
1211#pragma clang diagnostic pop
1212 } else if (strcmp("v2", var_str) == 0) {
1213#pragma clang diagnostic push
1214#pragma clang diagnostic ignored "-Wbad-function-cast"
1215 this->set_networkBottom(v2);
1216#pragma clang diagnostic pop
1217 } else {
1218#pragma clang diagnostic push
1219#pragma clang diagnostic ignored "-Wbad-function-cast"
1220 this->set_networkBottom(static_cast<enum NeuralNetworkType>(atoi(var_str)));
1221#pragma clang diagnostic pop
1222 }
1223 break;
1224 }
1225 case 10:
1226 {
1227 if (strcmp("Classified", var_str) == 0) {
1228#pragma clang diagnostic push
1229#pragma clang diagnostic ignored "-Wbad-function-cast"
1231#pragma clang diagnostic pop
1232 } else if (strcmp("Normal", var_str) == 0) {
1233#pragma clang diagnostic push
1234#pragma clang diagnostic ignored "-Wbad-function-cast"
1236#pragma clang diagnostic pop
1237 } else if (strcmp("Recognized", var_str) == 0) {
1238#pragma clang diagnostic push
1239#pragma clang diagnostic ignored "-Wbad-function-cast"
1241#pragma clang diagnostic pop
1242 } else {
1243#pragma clang diagnostic push
1244#pragma clang diagnostic ignored "-Wbad-function-cast"
1245 this->set_streamingSource(static_cast<enum StreamingType>(atoi(var_str)));
1246#pragma clang diagnostic pop
1247 }
1248 break;
1249 }
1250 case 11:
1251 {
1252 this->set_imageInput(strcmp(var_str, "true") == 0 || strcmp(var_str, "1") == 0);
1253 break;
1254 }
1255 case 12:
1256 {
1257 this->set_jpegStreamQuality(static_cast<int>(atoi(var_str)));
1258 break;
1259 }
1260 case 13:
1261 {
1262 this->set_jpegStreamStride(static_cast<int>(atoi(var_str)));
1263 break;
1264 }
1265 case 14:
1266 {
1267 this->set_frameRate(static_cast<int>(atoi(var_str)));
1268 break;
1269 }
1270 case 15:
1271 {
1272 this->set_runPipelineOnce(strcmp(var_str, "true") == 0 || strcmp(var_str, "1") == 0);
1273 break;
1274 }
1275 case 16:
1276 {
1277#ifdef __APPLE__
1278 this->set_frameNumber(static_cast<uint64_t>(atoll(var_str)));
1279#else
1280 this->set_frameNumber(static_cast<uint64_t>(atol(var_str)));
1281#endif
1282 break;
1283 }
1284 case 17:
1285 {
1286 strncpy(wb_vision_control_status::colourCalibration, var_str, 10);
1287 break;
1288 }
1289 }
1290 if (varIndex >= 0) {
1291 varIndex++;
1292 }
1293 } while(index < length);
1294#endif
1295 }
1296#endif
1297 };
1298
1305 private:
1307 PROPERTY(Resolutions, resolution)
1308 public:
1313 ResolutionType(Resolutions res = VGA): _resolution(res) {}
1314
1316 int width() const
1317 {
1318 static const int Widths[] = {160, 320, 640, 1280, 800};
1319 return Widths[_resolution];
1320 }
1321
1323 int height() const
1324 {
1325 static const int Heights[] = {120, 240, 480, 960, 600};
1326 return Heights[_resolution];
1327 }
1328 };
1329
1330}
1331
1332#endif
Resolution wrapper class for Resolutions enum Contains a Resolution and provides a number of convenie...
Provides a C++ wrapper around wb_vision_control_status.
void set_colourCalibration(const char *t_newValue)
void set_saveClassifiedImage(const bool &t_newValue)
void set_pipelineRunning(const bool &t_newValue)
VisionControlStatus(const std::string &t_str)
String Constructor.
void set_streamingSource(const enum StreamingType &t_newValue)
VisionControlStatus(const VisionControlStatus &t_other)
Copy Constructor.
void set_frameRate(const int &t_newValue)
void set_frameNumber(const uint64_t &t_newValue)
enum NeuralNetworkType & networkBottom()
void set_selectedCamera(const enum VisionCamera &t_newValue)
void set_jpegStreamQuality(const int &t_newValue)
VisionControlStatus(enum Resolutions t_cameraResolution=VGA, bool t_pipelineRunning=true, enum VisionCamera t_selectedCamera=Top, enum SaveFileType t_saveImage=None, bool t_saveClassifiedImage=false, enum NamedPipeline t_pipeline=Soccer, int t_chooseCamera=0, float t_confidence=0.8f, enum NeuralNetworkType t_networkTop=v2, enum NeuralNetworkType t_networkBottom=v2, enum StreamingType t_streamingSource=Normal, bool t_imageInput=false, int t_jpegStreamQuality=30, int t_jpegStreamStride=4, int t_frameRate=0, bool t_runPipelineOnce=false, uint64_t t_frameNumber=0, std::string t_colourCalibration="class", struct timeval t_imageTime={})
Create a new VisionControlStatus.
bool operator==(const VisionControlStatus &t_other) const
enum NeuralNetworkType & networkTop() const
void set_jpegStreamStride(const int &t_newValue)
void set_imageTime(const struct timeval &t_newValue)
bool operator!=(const VisionControlStatus &t_other) const
enum Resolutions & cameraResolution() const
void set_networkBottom(const enum NeuralNetworkType &t_newValue)
const char & colourCalibration(int t_i) const
enum StreamingType & streamingSource() const
void from_string(const std::string &t_str)
void set_runPipelineOnce(const bool &t_newValue)
VisionControlStatus(const struct wb_vision_control_status &t_other)
Copy Constructor.
void set_imageInput(const bool &t_newValue)
enum NamedPipeline & pipeline() const
void set_networkTop(const enum NeuralNetworkType &t_newValue)
void set_saveImage(const enum SaveFileType &t_newValue)
void set_confidence(const float &t_newValue)
enum NeuralNetworkType & networkBottom() const
const struct timeval & imageTime() const
void set_pipeline(const enum NamedPipeline &t_newValue)
enum VisionCamera & selectedCamera() const
void set_chooseCamera(const int &t_newValue)
enum SaveFileType & saveImage() const
VisionControlStatus & operator=(const VisionControlStatus &t_other)
Copy Assignment Operator.
enum NeuralNetworkType & networkTop()
void set_cameraResolution(const enum Resolutions &t_newValue)
/file APM_Interface.h
WHITEBOARD_POSTER_STRING_CONVERSION.
enum NeuralNetworkType networkBottom
neural network to run on bottom camera
float confidence
Confidence threshold for the neural net.
int frameRate
The current framerate that the pipeline is running at.
int jpegStreamQuality
The quality to compress jpeg images at for streaming can be between 0 and 100.
enum VisionCamera selectedCamera
Which camera to use.
bool imageInput
Use /tmp/test.ai2 as pipeline image rather then camera if true.
struct timeval imageTime
the time that the image was taken that this status message refers to
bool runPipelineOnce
run the pipeline one time only if true
uint64_t frameNumber
The current frame number reported by guvison.
enum SaveFileType saveImage
Whether to save the image used in the next iteration of the pipeline to file.
int jpegStreamStride
The stride to use when streaming jpeg images.
char colourCalibration[10]
the DLC file to use for segmentation, searched in $HOME/data/ with the .dlc extension
int chooseCamera
Choose which camera to run on (0-Top, 1-Bottom, 2-Both)
bool saveClassifiedImage
Whether to save the classified version of the image used in the next iteration of the pipeline to fil...
enum NamedPipeline pipeline
vision pipeline to be run
enum NeuralNetworkType networkTop
neural network to run on top camera
enum Resolutions cameraResolution
Resolution that the camera should caputre images at.
bool pipelineRunning
Whether the pipeline is running or not.
enum StreamingType streamingSource
The type of streaming to be used.
const char * wb_vision_control_status_to_string(const struct wb_vision_control_status *self, char *toString, size_t bufferSize)
Convert to a string.
struct wb_vision_control_status * wb_vision_control_status_from_string(struct wb_vision_control_status *self, const char *str)
Convert from a string.
const char * wb_vision_control_status_description(const struct wb_vision_control_status *self, char *descString, size_t bufferSize)
Convert to a description string.
SaveFileType
List of file types that vision can save images as.
@ JPG
Compressed JPEG.
@ AI3
Raw YUV422 Image, with JSON image info blob.
@ AI2
Raw YUV422 Image.
NamedPipeline
Enum listing available vision pipelines.
@ Streaming
Pipeline that just streams images.
@ OpenChallenge
2013 Open Challange Pipeline
@ HTWK
Pipeline that runs htwk's image algorithms and post soccer object info to mipal whiteboard.
@ OpenCVFaces
Pipeline to recognise faces.
@ Soccer
Soccer Pipeline.
@ Neural_Network
Pipeline to rec objects with a nn.
Resolutions
Resolutions Supported by Vision.
@ QVGA
320 x 240
@ SVGA
800 x 600
@ VGA
640 x 480
@ QQVGA
160 x 120
@ HD_4VGA
1280x960
#define VISION_CONTROL_STATUS_TO_STRING_BUFFER_SIZE
StreamingType
Streaming modes available in vision.
@ Recognized
Image showing only objects that have been recognised NYI.
@ Classified
Images that has been segmented into recognised colours.
@ Normal
Images straight from camera.
#define VISION_CONTROL_STATUS_DESC_BUFFER_SIZE
VisionCamera
Enum of available camera's that can be used by vision.
@ Bottom
Bottom Camera on the nao.
@ Top
Top Camera on the nao.
@ NUM_VISION_CAMERAS
Number of cameras used in vision.
NeuralNetworkType
List of neural network architectures that vision can run.
@ v2
Current default (separable convolutions)
@ BallOnly
PB_FCN v2 binary classifier.
@ Vanilla
PB_FCN.
@ VGANet
PB_FCN on VGA resolution.