Changeset 56 in pacpussensors
- Timestamp:
- Jun 27, 2014, 2:16:15 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/PtGreyCameras/Flea3Grabber.cpp
r53 r56 144 144 msleep(10); 145 145 } 146 147 146 } 148 147 … … 365 364 366 365 // Camera configuration 367 this->settings_[indice].auto_FrameRate = false; // Set auto frame rate366 this->settings_[indice].auto_FrameRate = true; // Set auto frame rate 368 367 this->settings_[indice].cam_FrameRate = 15.0; // Frame rates in frames per second = FlyCapture2::FRAMERATE_15 369 this->settings_[indice].auto_Gain = false; // Set auto gain368 this->settings_[indice].auto_Gain = true; // Set auto gain 370 369 this->settings_[indice].cam_Gain = 1.0; // Gain value in db 371 370 this->settings_[indice].auto_Exposure = true; // Set auto exposure 372 this->settings_[indice].cam_Exposure = 2.414; // Auto exposure in EV371 this->settings_[indice].cam_Exposure = 1.322; // Auto exposure in EV 373 372 this->settings_[indice].auto_Shutter = true; // Set auto shutter 374 373 this->settings_[indice].cam_Shutter = 66.639; // Shutter in miliseconds … … 377 376 this->settings_[indice].cam_start_point_left = 0; // Image left point (for standard modes only) 378 377 this->settings_[indice].cam_start_point_top = 0; // Image top point (for standard modes only) 379 this->settings_[indice].cam_width = 4096; // Image width (for standard modes only)380 this->settings_[indice].cam_height = 2160; // image height (for standard modes only)378 this->settings_[indice].cam_width = 1280; // Image width (for standard modes only) 379 this->settings_[indice].cam_height = 960; // image height (for standard modes only) 381 380 this->settings_[indice].cam_video_mode = FlyCapture2::VIDEOMODE_FORMAT7; // DCAM video modes 382 381 this->settings_[indice].cam_mode = FlyCapture2::MODE_0; // Camera modes for DCAM formats as well as Format7 … … 428 427 429 428 this->is_running = true; 429 bool triggered = false; 430 430 431 431 // Tmp matrice used because of intelligent pointer of OpenCV and "intelligent" memory free … … 514 514 } 515 515 516 cams.push_back(new FlyCapture2::Camera); // FlyCapture camera class 516 cams.push_back(new FlyCapture2::Camera); // FlyCapture camera class 517 517 518 518 // Connect to a camerak … … 550 550 camInfo.firmwareVersion, 551 551 camInfo.firmwareBuildTime);*/ 552 552 553 553 // Query for available Format 7 modes 554 554 FlyCapture2::Format7Info fmt7Info; … … 698 698 ComponentManager::getInstance()->stop(name()); 699 699 } 700 701 triggered = true; 700 702 } 701 703 … … 715 717 } 716 718 } 719 717 720 //============================================================================================================ 718 721 … … 747 750 cams[masterCamera_]->FireSoftwareTrigger(); 748 751 usleep(50000); 752 749 753 cams[masterCamera_]->FireSoftwareTrigger(); 750 754 usleep(50000); 751 755 } 756 757 img_sending_ = new ShMem("Flea3Grabber_sending", settings_[0].mMaxImageOutputSize); 758 752 759 753 760 road_time_t time; … … 762 769 LOG_ERROR(error.GetDescription()); 763 770 continue; 764 } 765 time = road_time(); 766 } 771 } 772 } 773 774 time = road_time(); 767 775 768 776 //cout << settings_[1].timeStamp.microSeconds - settings_[0].timeStamp.microSeconds << endl; … … 832 840 cv::waitKey(1); 833 841 } 834 842 835 843 ///////////////////// 836 844 // Write images to disk … … 943 951 //++imageCount; 944 952 } 953 954 // Has to change 955 this->img_sending_->write((void*)correctedImg[0].data, settings_[0].mMaxImageOutputSize); 945 956 } 946 957 … … 948 959 { 949 960 //====================================== Camera finalization ================================================= 950 LOG_INFO( "Finished grabbing images!");961 LOG_INFO(QString("Finished grabbing images!" + QString::number(settings_[i].cam_serial))); 951 962 // Stop capturing images 952 963 error = cams[i]->StopCapture(); -
trunk/PtGreyCameras/Flea3Grabber.h
r53 r56 135 135 float rot_[3], trans_[3]; 136 136 137 ShMem * img_sending_; 138 137 139 std::vector<camSetting> settings_; 138 140 std::vector<ShMem*> shmem_images_; -
trunk/StereoVisionDisparity/DisparityMap.cpp
r53 r56 144 144 THREAD_ALIVE = true; 145 145 start(); 146 147 emit minimumDisparityChanged(this->min_disp); 148 emit numberOfDisparityChanged(this->num_disp); 149 emit SADWindowSizeChanged(this->sbm_SADWindowSize); 150 emit textureTresholdChanged(this->sbm_textureThreshold); 151 emit uniquenessRatioChanged(this->sbm_uniquenessRatio); 146 152 } 147 153 … … 577 583 } 578 584 585 586 //////////////////////////////////////////////////////////////////////////////// 587 void DisparityMap::setMinimumDisparity(int minimum_disp) 588 { 589 this->min_disp = minimum_disp; 590 591 emit minimumDisparityChanged(this->min_disp); 592 } 593 594 595 //////////////////////////////////////////////////////////////////////////////// 596 void DisparityMap::setNumberOfDisparity(int numberOfDisparity) 597 { 598 // Must be a multiple of 16 599 this->num_disp = numberOfDisparity & ~15; 600 if (this->num_disp < 16) 601 this->num_disp = 16; 602 603 emit numberOfDisparityChanged(this->num_disp); 604 } 605 606 607 //////////////////////////////////////////////////////////////////////////////// 608 void DisparityMap::setSADWindowSize(int SADWindowSize) 609 { 610 // Must be an odd number 611 this->sbm_SADWindowSize = SADWindowSize | 1; 612 613 emit SADWindowSizeChanged(this->sbm_SADWindowSize); 614 } 615 616 617 //////////////////////////////////////////////////////////////////////////////// 618 void DisparityMap::setTextureTreshold(int textureTreshold) 619 { 620 this->sbm_textureThreshold = textureTreshold; 621 622 emit textureTresholdChanged(this->sbm_textureThreshold); 623 } 624 625 626 //////////////////////////////////////////////////////////////////////////////// 627 void DisparityMap::setUniquenessRatio(int uniquenessRatio) 628 { 629 this->sbm_uniquenessRatio = uniquenessRatio; 630 631 emit uniquenessRatioChanged(this->sbm_uniquenessRatio); 632 } 633 634 579 635 //////////////////////////////////////////////////////////////////////////////// 580 636 /// CalcDisparityMap … … 640 696 Right_img_gray = Right_img_exp; 641 697 } 698 699 /*cv::namedWindow("Disparity trackbar", CV_WINDOW_NORMAL); 700 cv::createTrackbar("sbm_preFilterCap", "Disparity trackbar", &sbm_preFilterCap, 63); 701 cv::createTrackbar("sbm_preFilterSize", "Disparity trackbar", &sbm_preFilterSize, 250); 702 cv::createTrackbar("sbm_SADWindowSize", "Disparity trackbar", &sbm_SADWindowSize, 250); 703 cv::createTrackbar("min_disp", "Disparity trackbar", &min_disp, 250); 704 cv::createTrackbar("num_disp", "Disparity trackbar", &num_disp, 250); 705 cv::createTrackbar("sbm_textureThreshold", "Disparity trackbar", &sbm_textureThreshold, 250); 706 cv::createTrackbar("sbm_uniquenessRatio", "Disparity trackbar", &sbm_uniquenessRatio, 250); 707 cv::createTrackbar("sbm_speckleWindowSize", "Disparity trackbar", &sbm_speckleWindowSize, 250); 708 cv::createTrackbar("sbm_speckleRange", "Disparity trackbar", &sbm_speckleRange, 250); 709 this->sbm_SADWindowSize = (this->sbm_SADWindowSize % 2 > 0) ? this->sbm_SADWindowSize : this->sbm_SADWindowSize + 1; 710 this->num_disp = (this->num_disp % 16 == 0) ? this->num_disp : this->num_disp - (this->num_disp % 16);*/ 642 711 643 712 // Configuration … … 666 735 // the parameter to a positive value, it will be implicitly multiplied by 16. Normally, 1 or 2 is 667 736 // good enough. 668 737 669 738 // Calculate the disparity image (16S = scaled by 16, must be divided by 16; 32F = original value) 670 739 sbm(Left_img_gray, Right_img_gray, Disp_map_exp, CV_16S); … … 701 770 sgbm.disp12MaxDiff = this->sgbm_disp12MaxDiff; // Maximum allowed difference (in integer pixel units) in the left-right disparity check. Set it to 702 771 // a non-positive value to disable the check. 703 sgbm.fullDP = type == SGBM; // Set it to true to run the full-scale two-pass dynamic programming algorithm.772 sgbm.fullDP = type == SGBM; // Set it to true to run the full-scale two-pass dynamic programming algorithm. 704 773 // It will consume O(W*H*numDisparities) bytes, which is large for 640x480 stereo 705 774 // and huge for HD-size pictures. -
trunk/StereoVisionDisparity/DisparityMap.h
r50 r56 39 39 public ComponentBase 40 40 { 41 Q_OBJECT 41 42 public: 42 43 //============================= DEFAULT ELEMENTS =============================================== … … 62 63 63 64 void InitDefault(); 65 66 public Q_SLOTS: 67 void setMinimumDisparity(int minimum_disp); 68 void setNumberOfDisparity(int numberOfDisparity); 69 void setSADWindowSize(int SADWindowSize); 70 void setTextureTreshold(int textureTreshold); 71 void setUniquenessRatio(int uniquenessRatio); 72 73 Q_SIGNALS: 74 void minimumDisparityChanged(int minDisp); 75 void numberOfDisparityChanged(int numOfDisp); 76 void SADWindowSizeChanged(int SADWinSize); 77 void textureTresholdChanged(int textTresh); 78 void uniquenessRatioChanged(int uniqRatio); 64 79 65 80 private: -
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 } -
trunk/StereoVisionDisparity/ObstacleDetectionComponent.h
r53 r56 94 94 TimestampedStructImage DispOutImageHeader; // Header for the output disp image 95 95 96 void * ref_mem;97 void * dispin_mem;98 void * mask1_mem;99 void * mask2_mem;100 void * dispout_mem;96 void * ref_mem; 97 void * dispin_mem; 98 void * mask1_mem; 99 void * mask2_mem; 100 void * dispout_mem; 101 101 102 102 size_t ref_mem_size; // Image shared memory position size … … 114 114 ShMem * shmem_mask2; // Shared memory control access to the image data (obstacles mask) 115 115 ShMem * shmem_dispout; // Shared memory control access to the image data (disparity map 16) 116 117 ShMem * shmem_dispMapNormalized; 118 ShMem * shmem_result; 116 119 117 120 cv::Mat CurrentReferenceFrame; // Reference image
Note:
See TracChangeset
for help on using the changeset viewer.