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

Vision component updated for StereoVision for PointGrey Flea3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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                        }
Note: See TracChangeset for help on using the changeset viewer.