Changeset 56 in pacpussensors for trunk/StereoVisionDisparity/ObstacleDetectionComponent.cpp
- Timestamp:
- Jun 27, 2014, 2:16:15 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/StereoVisionDisparity/ObstacleDetectionComponent.cpp
r53 r56 43 43 static const string ObstacleDetectionMemoryName_dispout = "ObstacleDetection-disp"; 44 44 45 static const string ObstacleDetectionMemoryName_dispMapNorm = "ObstacleDetection-dispMapNorm"; 46 static const string ObstacleDetectionMemoryName_result = "ObstacleDetection-result"; 47 45 48 ////////////////////////////////////////////////////////////////////////// 46 49 /* ComparePoints1 … … 134 137 this->shmem_dispout = NULL; 135 138 139 if(this->shmem_dispMapNormalized) 140 delete shmem_dispMapNormalized; 141 142 this->shmem_dispMapNormalized = NULL; 143 144 if(this->shmem_result) 145 delete shmem_result; 146 147 this->shmem_result = NULL; 136 148 } 137 149 … … 169 181 this->shmem_dispout = new ShMem(ObstacleDetectionMemoryName_dispout.c_str(), this->dispout_mem_size); 170 182 183 this->shmem_dispMapNormalized = new ShMem(ObstacleDetectionMemoryName_dispMapNorm.c_str(), (this->cam_width * this->cam_height)); 184 185 this->shmem_result = new ShMem(ObstacleDetectionMemoryName_result.c_str(), (this->cam_width * this->cam_height * 3)); 186 171 187 // Run thread 172 188 THREAD_ALIVE = true; … … 214 230 215 231 this->shmem_dispout = NULL; 232 233 if(this->shmem_dispMapNormalized) 234 delete shmem_dispMapNormalized; 235 236 this->shmem_dispMapNormalized = NULL; 237 238 if(this->shmem_result) 239 delete shmem_result; 240 241 this->shmem_result = NULL; 216 242 217 243 // Free the malloc memories … … 221 247 free(this->mask2_mem); 222 248 free(this->dispout_mem); 223 224 249 } 225 250 … … 452 477 } 453 478 479 //memcpy(this->dispMapNorm_mem, &this->dispMapNormImageHeader, sizeof(TimestampedStructImage)); 480 //memcpy((void*)((TimestampedStructImage*)this->dispMapNorm_mem + 1), (void*)Disp_map.data, this->dispMapNormImageHeader.image.data_size); 481 this->shmem_dispMapNormalized->write((void*)Disp_map.data, (this->cam_width * this->destiny_roi_height)); 482 454 483 // Image to detect near obstacles 455 484 cv::Mat v_disp_map2 = v_disp_map.clone(); … … 540 569 541 570 // ----------------- Apply the mask in the reference image ------------------ 571 572 std::vector<cv::Mat> channels(3); 573 cv::Mat reference; 574 if(this->cam_channels == 1) 575 { 576 cv::cvtColor((this->CurrentReferenceFrame(cv::Rect(this->destiny_roi_x, this->destiny_roi_y, this->destiny_roi_width, this->destiny_roi_height))).clone(), reference, CV_GRAY2BGR); 577 } 578 else 579 { 580 reference = (this->CurrentReferenceFrame(cv::Rect(this->destiny_roi_x, this->destiny_roi_y, this->destiny_roi_width, this->destiny_roi_height))).clone(); 581 } 582 583 cv::split(reference, channels); 584 585 masks.second = 1 - masks.second; 586 channels[1] = masks.second.mul(channels[0]); // Activate the red color as obstacles 587 channels[2] = masks.second.mul(channels[1]); // Activate the red color as obstacles 588 589 //masks.second = masks.second - masks.first; 590 //channels[0] = (1 - masks.second).mul(channels[0]); // Activate the yellow color for unclassified area 591 592 cv::merge(channels, reference); 593 594 this->shmem_result->write((void*)reference.data, (this->destiny_roi_width * this->destiny_roi_height * 3)); 595 542 596 if(this->showdebug) 543 597 { 544 std::vector<cv::Mat> channels(3); 545 cv::Mat reference; 546 if(this->cam_channels == 1) 547 { 548 cv::Mat img_gray = (this->CurrentReferenceFrame(cv::Rect(this->destiny_roi_x, this->destiny_roi_y, this->destiny_roi_width, this->destiny_roi_height))).clone(); 549 cv::cvtColor(img_gray, reference, CV_GRAY2BGR); 550 } 551 else 552 { 553 reference = (this->CurrentReferenceFrame(cv::Rect(this->destiny_roi_x, this->destiny_roi_y, this->destiny_roi_width, this->destiny_roi_height))).clone(); 554 } 555 556 cv::split(reference, channels); 557 558 masks.second = 1 - masks.second; 559 channels[0] = masks.second.mul(channels[0]); // Activate the red color as obstacles 560 channels[1] = masks.second.mul(channels[1]); // Activate the red color as obstacles 561 562 masks.second = masks.second - masks.first; 563 channels[0] = (1 - masks.second).mul(channels[0]); // Activate the yellow color for unclassified area 564 565 cv::merge(channels, reference); 566 567 cv::namedWindow("ObstacleDetectionComponent - Final Classification",CV_WINDOW_AUTOSIZE); 598 cv::namedWindow("ObstacleDetectionComponent - Final Classification", CV_WINDOW_AUTOSIZE); 568 599 cv::imshow("ObstacleDetectionComponent - Final Classification", reference); 569 600 }
Note:
See TracChangeset
for help on using the changeset viewer.