Changeset 56 in pacpussensors


Ignore:
Timestamp:
06/27/14 14:16:15 (10 years ago)
Author:
phudelai
Message:

Vision component updated for StereoVision for PointGrey Flea3

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/PtGreyCameras/Flea3Grabber.cpp

    r53 r56  
    144144                        msleep(10);
    145145                }
    146                                
    147146        }
    148147
     
    365364       
    366365        // Camera configuration
    367         this->settings_[indice].auto_FrameRate = false;                                 // Set auto frame rate
     366        this->settings_[indice].auto_FrameRate = true;                                  // Set auto frame rate
    368367        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 gain
     368        this->settings_[indice].auto_Gain = true;                                               // Set auto gain
    370369        this->settings_[indice].cam_Gain = 1.0;                                                 // Gain value in db
    371370        this->settings_[indice].auto_Exposure = true;                                           // Set auto exposure
    372         this->settings_[indice].cam_Exposure = 2.414;                                           // Auto exposure in EV
     371        this->settings_[indice].cam_Exposure = 1.322;                                           // Auto exposure in EV
    373372        this->settings_[indice].auto_Shutter = true;                                            // Set auto shutter
    374373        this->settings_[indice].cam_Shutter = 66.639;                                           // Shutter in miliseconds
     
    377376        this->settings_[indice].cam_start_point_left = 0;                                       // Image left point (for standard modes only)
    378377        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)
    381380        this->settings_[indice].cam_video_mode = FlyCapture2::VIDEOMODE_FORMAT7;                                // DCAM video modes
    382381        this->settings_[indice].cam_mode = FlyCapture2::MODE_0;                                                         // Camera modes for DCAM formats as well as Format7
     
    428427
    429428        this->is_running = true;
     429        bool triggered = false;
    430430
    431431        // Tmp matrice used because of intelligent pointer of OpenCV and "intelligent" memory free
     
    514514                }
    515515       
    516                 cams.push_back(new FlyCapture2::Camera);        // FlyCapture camera class     
     516                cams.push_back(new FlyCapture2::Camera);        // FlyCapture camera class
    517517
    518518                // Connect to a camerak
     
    550550                        camInfo.firmwareVersion,
    551551                        camInfo.firmwareBuildTime);*/
    552            
     552
    553553                // Query for available Format 7 modes
    554554                FlyCapture2::Format7Info fmt7Info;
     
    698698                                ComponentManager::getInstance()->stop(name());
    699699                        }
     700
     701                        triggered = true;
    700702                }
    701703
     
    715717                        }
    716718                }
     719
    717720                //============================================================================================================
    718721       
     
    747750                cams[masterCamera_]->FireSoftwareTrigger();
    748751                usleep(50000);
     752
    749753                cams[masterCamera_]->FireSoftwareTrigger();
    750754                usleep(50000);
    751755        }
     756
     757        img_sending_ = new ShMem("Flea3Grabber_sending", settings_[0].mMaxImageOutputSize);
     758
    752759
    753760        road_time_t time;
     
    762769                                        LOG_ERROR(error.GetDescription());
    763770                                        continue;
    764                         }
    765                         time = road_time();
    766                 }
     771                        }                       
     772                }
     773
     774                time = road_time();
    767775
    768776                //cout << settings_[1].timeStamp.microSeconds - settings_[0].timeStamp.microSeconds << endl;
     
    832840                                cv::waitKey(1);
    833841                        }
    834                
     842
    835843                        /////////////////////
    836844                        // Write images to disk
     
    943951                        //++imageCount;
    944952                }
     953
     954                // Has to change
     955                this->img_sending_->write((void*)correctedImg[0].data, settings_[0].mMaxImageOutputSize);
    945956        }
    946957               
     
    948959        {
    949960                //====================================== Camera finalization =================================================
    950                 LOG_INFO("Finished grabbing images!");
     961                LOG_INFO(QString("Finished grabbing images!" + QString::number(settings_[i].cam_serial)));
    951962                // Stop capturing images
    952963                error = cams[i]->StopCapture();
  • trunk/PtGreyCameras/Flea3Grabber.h

    r53 r56  
    135135        float rot_[3], trans_[3];
    136136
     137        ShMem * img_sending_;
     138
    137139        std::vector<camSetting> settings_;
    138140        std::vector<ShMem*> shmem_images_;
  • trunk/StereoVisionDisparity/DisparityMap.cpp

    r53 r56  
    144144        THREAD_ALIVE = true;
    145145        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);
    146152}
    147153
     
    577583}
    578584
     585
     586////////////////////////////////////////////////////////////////////////////////
     587void DisparityMap::setMinimumDisparity(int minimum_disp)
     588{
     589        this->min_disp = minimum_disp;
     590
     591        emit minimumDisparityChanged(this->min_disp);
     592}
     593
     594
     595////////////////////////////////////////////////////////////////////////////////
     596void 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////////////////////////////////////////////////////////////////////////////////
     608void 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////////////////////////////////////////////////////////////////////////////////
     618void DisparityMap::setTextureTreshold(int textureTreshold)
     619{
     620        this->sbm_textureThreshold = textureTreshold;
     621
     622        emit textureTresholdChanged(this->sbm_textureThreshold);
     623}
     624
     625
     626////////////////////////////////////////////////////////////////////////////////
     627void DisparityMap::setUniquenessRatio(int uniquenessRatio)
     628{
     629        this->sbm_uniquenessRatio = uniquenessRatio;
     630
     631        emit uniquenessRatioChanged(this->sbm_uniquenessRatio);
     632}
     633
     634
    579635////////////////////////////////////////////////////////////////////////////////
    580636///     CalcDisparityMap
     
    640696                        Right_img_gray = Right_img_exp;
    641697                }
     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);*/
    642711
    643712                // Configuration
     
    666735                                                                                                                                        // the parameter to a positive value, it will be implicitly multiplied by 16. Normally, 1 or 2 is
    667736                                                                                                                                        // good enough.
    668                
     737
    669738                // Calculate the disparity image (16S = scaled by 16, must be divided by 16; 32F = original value)
    670739                sbm(Left_img_gray, Right_img_gray, Disp_map_exp, CV_16S);
     
    701770                sgbm.disp12MaxDiff = this->sgbm_disp12MaxDiff;                          // Maximum allowed difference (in integer pixel units) in the left-right disparity check. Set it to
    702771                                                                                                                                        // 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.
    704773                                                                                                                                        // It will consume O(W*H*numDisparities) bytes, which is large for 640x480 stereo
    705774                                                                                                                                        // and huge for HD-size pictures.
  • trunk/StereoVisionDisparity/DisparityMap.h

    r50 r56  
    3939                                                                                                public ComponentBase
    4040{
     41        Q_OBJECT
    4142public:
    4243        //============================= DEFAULT ELEMENTS ===============================================
     
    6263
    6364        void InitDefault();
     65
     66public 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
     73Q_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);
    6479
    6580private:
  • trunk/StereoVisionDisparity/ObstacleDetectionComponent.cpp

    r53 r56  
    4343static const string ObstacleDetectionMemoryName_dispout = "ObstacleDetection-disp";
    4444
     45static const string ObstacleDetectionMemoryName_dispMapNorm = "ObstacleDetection-dispMapNorm";
     46static const string ObstacleDetectionMemoryName_result = "ObstacleDetection-result";
     47
    4548//////////////////////////////////////////////////////////////////////////
    4649/*      ComparePoints1
     
    134137        this->shmem_dispout = NULL;
    135138
     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;
    136148}
    137149
     
    169181        this->shmem_dispout = new ShMem(ObstacleDetectionMemoryName_dispout.c_str(), this->dispout_mem_size);
    170182
     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
    171187        // Run thread
    172188        THREAD_ALIVE = true;
     
    214230
    215231                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;
    216242
    217243                // Free the malloc memories
     
    221247                free(this->mask2_mem);
    222248                free(this->dispout_mem);
    223 
    224249        }
    225250
     
    452477                        }
    453478
     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
    454483                        // Image to detect near obstacles
    455484                        cv::Mat v_disp_map2 = v_disp_map.clone();
     
    540569
    541570                        // ----------------- 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
    542596                        if(this->showdebug)
    543597                        {
    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);
    568599                                cv::imshow("ObstacleDetectionComponent - Final Classification", reference);
    569600                        }
  • trunk/StereoVisionDisparity/ObstacleDetectionComponent.h

    r53 r56  
    9494        TimestampedStructImage DispOutImageHeader;              // Header for the output disp image
    9595
    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;
    101101
    102102        size_t ref_mem_size;            // Image shared memory position size
     
    114114        ShMem * shmem_mask2;            // Shared memory control access to the image data (obstacles mask)
    115115        ShMem * shmem_dispout;          // Shared memory control access to the image data (disparity map 16)
     116
     117        ShMem * shmem_dispMapNormalized;
     118        ShMem * shmem_result;
    116119
    117120        cv::Mat CurrentReferenceFrame;  // Reference image
Note: See TracChangeset for help on using the changeset viewer.