@@ -360,7 +360,7 @@ int main(int argc, char * argv[])
360
360
361
361
// Render blobs, and calculate average coordinates for each bucket list
362
362
// on every 10th frame
363
- if (ctr == 10 ) {
363
+ if (ctr == 5 ) {
364
364
365
365
// Iterate through every bucket
366
366
for (it = blob_buckets.begin (); it != blob_buckets.end (); it++) {
@@ -577,7 +577,7 @@ int main(int argc, char * argv[])
577
577
uint8_t left_ardu_coords, right_ardu_coords;
578
578
579
579
// if there are coordinates to send
580
- if (prev_left_valid || prev_right_valid) {
580
+ if ((ctr == 0 ) && ( prev_left_valid || prev_right_valid) ) {
581
581
582
582
// compress left coordinates into a byte
583
583
if (prev_left_valid) {
@@ -601,94 +601,55 @@ int main(int argc, char * argv[])
601
601
right_ardu_coords = ((right_x_ardu & 0xf ) << 4 ) |
602
602
(right_y_ardu & 0xf );
603
603
}
604
-
605
- <<<<<<< HEAD
606
- // SEND FIRST COORDINATE
607
- // if left is valid, send it
608
- if (prev_left_valid) {
609
- // send
610
- ardu << left_ardu_coords;
611
- }
612
- // else, send the right coordinate twice
613
- else {
614
- ardu << right_ardu_coords;
615
- }
616
-
617
- cout << " FIRST OUT" << endl;
618
-
619
- // TODO wait for 1 byte from arduino
620
- while (ardu.get () != 55 ) {
621
- // stall
622
- }
623
-
624
- // SEND SECOND COORDIANTE
625
- // if right is valid, send it
626
- if (prev_right_valid) {
627
- ardu << right_ardu_coords;
628
- }
629
- // else, send the left coordinate twice
630
- else {
631
- ardu << left_ardu_coords;
632
- }
633
604
634
- // cout << "Blob avg coordinates: (" << x_coord << ", " << y_coord << ")" << endl;
635
- =======
636
605
// SEND FIRST COORDINATE
637
606
// if left is valid, send it
638
607
if (prev_left_valid) {
639
608
// send
640
609
ardu << left_ardu_coords;
641
- printf (" sending : (%d, %d), " , left_ardu_coords >> 4 ,
610
+ printf (" red : (%d, %d), " , left_ardu_coords >> 4 ,
642
611
left_ardu_coords & 0xf );
643
612
}
644
613
// else, right coordinate is guaranteed to be valid so
645
614
// send the right coordinate twice
646
615
else {
647
616
ardu << right_ardu_coords;
648
- printf (" sending : (%d, %d), " , right_ardu_coords >> 4 ,
617
+ printf (" red : (%d, %d), " , right_ardu_coords >> 4 ,
649
618
right_ardu_coords & 0xf );
650
619
}
651
620
652
- /*
653
621
while (ardu.get () != 55 ) {
654
622
// stall and wait on arduino
655
623
}
656
- */
657
- >>>>>>> 2e627b2b7dddee21fee982b7f40c789e1fd77a8f
658
-
624
+
659
625
// SEND SECOND COORDIANTE
660
626
// if right is valid, send it
661
627
if (prev_right_valid) {
628
+ if (prev_left_valid) {
629
+ sleep (1 );
630
+ }
631
+
662
632
ardu << right_ardu_coords;
663
- printf (" (%d, %d)\n " , right_ardu_coords >> 4 ,
633
+ printf (" green: (%d, %d)\n " , right_ardu_coords >> 4 ,
664
634
right_ardu_coords & 0xf );
665
635
}
666
636
// else, left coordinate is guaranteed to be valid so
667
637
// send the left coordinate again
668
638
else {
669
639
ardu << left_ardu_coords;
670
- printf (" (%d, %d)\n " , left_ardu_coords >> 4 ,
640
+ printf (" green/red: (%d, %d)\n " , left_ardu_coords >> 4 ,
671
641
left_ardu_coords & 0xf );
672
642
}
673
643
674
- <<<<<<< HEAD
675
- cout << " SECOND OUT" << endl;
676
-
677
- // TODO wait for 1 byte from arduino
678
- while (ardu.get () != 55 ) {
679
- // stall
680
- }
681
- =======
682
- /*
683
644
while (ardu.get () != 55 ) {
684
- // stall and wait on arduino
645
+ // stall
685
646
}
686
- */
687
- >>>>>>> 2e627b2b7dddee21fee982b7f40c789e1fd77a8f
688
-
689
647
}
690
648
691
649
t = (double ) cvGetTickCount () - t;
650
+ if (ctr==0 ) {
651
+ printf (" sending " );
652
+ }
692
653
printf ( " total frame processing time = %g ms\n " ,
693
654
t/((double )cvGetTickFrequency ()*1000 .));
694
655
0 commit comments