Page 1013 - 완) I MDP 프로젝트 작품 보고서(전체과 1학년)1.6
P. 1013

else {

                            destroyWindow("Difference Image");
                            destroyWindow("Threshold Image");
                            destroyWindow("Final Threshold Image");
                    }

                    SerchTrash(thresholdImage);
            }


            void SerchTrash(Mat thresholdImage){//쓰레기  찾기
                    bool objectDetected = false;
                    Mat temp;



                    int theObject[2];
                    Rect objectBoundingRectangle;



                    thresholdImage.copyTo(temp);
                    vector< vector<Point> > contours;
                    vector<Vec4i> hierarchy;


            findContours(temp,contours,hierarchy,CV_RETR_EXTERNAL,CV_CHAIN_APPROX_SIMPLE );



            /*물체가  감지되었는지  검사한다.*/
                    objectDetected = (contours.size()>0)? true:false;


            /*물체가  감지가  됐으면  그  물체의  위치를  읽어오고  쓰레기통의  이전  위치에서  센싱할  범위안
            에  있는지  감지해서  그  범위안에  있으면  같은  쓰레기로  인식을  하여  쓰레기의  위치를  입력해

            준다.
            또한  새로운  쓰레기가  들어왔는지  감지하여  값을  넣어준다.*/
                    if(objectDetected){
                            vector< vector<Point> > largestContourVec;
                            largestContourVec = contours;

                            for(int i=0;i<largestContourVec.size();i++){
                                    objectBoundingRectangle                                                 =
            boundingRect(largestContourVec.at(i));
                                    int                                xpos                                 =

            objectBoundingRectangle.x+objectBoundingRectangle.width/2;
                                    int                                ypos                                 =




                                                        -  1006  -
   1008   1009   1010   1011   1012   1013   1014   1015   1016   1017   1018