@@ -441,7 +441,7 @@ void LaneDetector::segment_homography_transform(vector<segment_t>& lines)
441
441
}
442
442
}
443
443
444
- void LaneDetector::send_visualize_image_to_queue (
444
+ void LaneDetector::send_sucess_visualize_image_thread (
445
445
/* Images */
446
446
cv::Mat distorted_image, cv::Mat canny_image,
447
447
cv::Mat outer_threshold_image, cv::Mat inner_threshold_image,
@@ -485,6 +485,75 @@ void LaneDetector::send_visualize_image_to_queue(
485
485
ROS_INFO (" phi:%f | d:%f" , phi, d);
486
486
}
487
487
488
+ void LaneDetector::send_failed_visualize_image_thread (
489
+ /* Images */
490
+ cv::Mat distorted_image, cv::Mat canny_image,
491
+ cv::Mat outer_threshold_image, cv::Mat inner_threshold_image)
492
+ {
493
+ cv::Mat lane_mark_image = distorted_image;
494
+
495
+ #if 1
496
+ /* Bird view image */
497
+ cv::Mat bird_view_image;
498
+ draw_bird_view_image (distorted_image, bird_view_image);
499
+ #endif
500
+
501
+ draw_region_of_interest (lane_mark_image);
502
+
503
+ /* Draw car status */
504
+ putText (lane_mark_image, " Failed to estimate the lane" , Point (10 , 15 ),
505
+ FONT_HERSHEY_COMPLEX_SMALL, 0.7 , Scalar (0 , 0 , 255 ));
506
+
507
+ publish_images (
508
+ lane_mark_image, canny_image,
509
+ outer_threshold_image, inner_threshold_image,
510
+ bird_view_image
511
+ );
512
+
513
+ ROS_INFO (" Failed to estimate the lane" );
514
+ }
515
+
516
+
517
+ void LaneDetector::send_visualize_image (
518
+ /* Images */
519
+ cv::Mat& distorted_image, cv::Mat& canny_image,
520
+ cv::Mat& outer_threshold_image, cv::Mat& inner_threshold_image,
521
+ /* Segments */
522
+ vector<segment_t >& outer_lines, vector<segment_t >& inner_lines,
523
+ /* Pose */
524
+ float & d, float & phi, xenobot::segmentArray& segments_msg)
525
+ {
526
+ thread send_image_thread (
527
+ &LaneDetector::send_sucess_visualize_image_thread,
528
+ this ,
529
+ distorted_image,
530
+ canny_image,
531
+ outer_threshold_image,
532
+ inner_threshold_image,
533
+ outer_lines, inner_lines,
534
+ d, phi, segments_msg
535
+ );
536
+
537
+ send_image_thread.detach ();
538
+ }
539
+
540
+ void LaneDetector::send_visualize_image (
541
+ /* Images */
542
+ cv::Mat& distorted_image, cv::Mat& canny_image,
543
+ cv::Mat& outer_threshold_image, cv::Mat& inner_threshold_image)
544
+ {
545
+ thread send_image_thread (
546
+ &LaneDetector::send_failed_visualize_image_thread,
547
+ this ,
548
+ distorted_image,
549
+ canny_image,
550
+ outer_threshold_image,
551
+ inner_threshold_image
552
+ );
553
+
554
+ send_image_thread.detach ();
555
+ }
556
+
488
557
bool LaneDetector::lane_estimate (cv::Mat& raw_image, float & final_d, float & final_phi)
489
558
{
490
559
/* Find the region of interest for lane */
@@ -540,7 +609,13 @@ bool LaneDetector::lane_estimate(cv::Mat& raw_image, float& final_d, float& fina
540
609
segments_side_recognize (inner_cv_lines, inner_xeno_lines, inner_threshold_image);
541
610
542
611
if (outer_xeno_lines.size () == 0 && inner_xeno_lines.size () == 0 ) {
543
- pose_available = false ;
612
+ send_visualize_image (
613
+ raw_image,
614
+ canny_image,
615
+ outer_threshold_image,
616
+ inner_threshold_image
617
+ );
618
+
544
619
return false ;
545
620
}
546
621
@@ -644,7 +719,13 @@ bool LaneDetector::lane_estimate(cv::Mat& raw_image, float& final_d, float& fina
644
719
}
645
720
646
721
if (vote_box[highest_vote_i][highest_vote_j] < HISTOGRAM_FILTER_THRESHOLD) {
647
- pose_available = false ;
722
+ send_visualize_image (
723
+ raw_image,
724
+ canny_image,
725
+ outer_threshold_image,
726
+ inner_threshold_image
727
+ );
728
+
648
729
return false ;
649
730
}
650
731
@@ -696,14 +777,22 @@ bool LaneDetector::lane_estimate(cv::Mat& raw_image, float& final_d, float& fina
696
777
}
697
778
}
698
779
699
- if (phi_sample_cnt == 0 ) return false ;
700
- if (d_sample_cnt == 0 ) return false ;
780
+ if (phi_sample_cnt == 0 || d_sample_cnt == 0 ) {
781
+ send_visualize_image (
782
+ raw_image,
783
+ canny_image,
784
+ outer_threshold_image,
785
+ inner_threshold_image
786
+ );
787
+
788
+ return false ;
789
+ }
701
790
702
791
phi_mean /= (float )phi_sample_cnt;
703
792
d_mean /= (float )d_sample_cnt;
704
793
705
- final_d = pose_d = d_mean;
706
- final_phi = pose_phi = phi_mean;
794
+ final_d = d_mean;
795
+ final_phi = phi_mean;
707
796
708
797
#if 1
709
798
// ROS message
@@ -713,9 +802,7 @@ bool LaneDetector::lane_estimate(cv::Mat& raw_image, float& final_d, float& fina
713
802
segments_msg.segments .push_back (segment);
714
803
#endif
715
804
716
- thread send_image_thread (
717
- &LaneDetector::send_visualize_image_to_queue,
718
- this ,
805
+ send_visualize_image (
719
806
raw_image,
720
807
canny_image,
721
808
outer_threshold_image,
@@ -724,8 +811,6 @@ bool LaneDetector::lane_estimate(cv::Mat& raw_image, float& final_d, float& fina
724
811
final_d, final_phi, segments_msg
725
812
);
726
813
727
- send_image_thread.detach ();
728
-
729
814
return true ;
730
815
}
731
816
0 commit comments