dò tìm vật mốc để điều khiển xe lăn điện đến đích dùng stereo camera

97 404 0
dò tìm vật mốc để điều khiển xe lăn điện đến đích dùng stereo camera

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

BỘ GIÁO DỤC VÀ ĐÀO TẠO TRƯỜNG ĐẠI HỌC SƯ PHẠM KỸ THUẬT THÀNH PHỐ HỒ CHÍ MINH LUẬN VĂN THẠC SĨ NGÔ BÁ VIỆT DÒ TÌM VẬT MỐC ĐỂ ĐIỀU KHIỂN XE LĂN ĐIỆN ĐẾN ĐÍCH DÙNG STEREO CAMERA NGÀNH: KỸ THUẬT ĐIỆN TỬ - 605270 S KC 0 Tp Hồ Chí Minh, tháng 11 năm 2013 BỘ GIÁO DỤC VÀ ĐÀO TẠO TRƯỜNG ĐẠI HỌC SƯ PHẠM KỸ THUẬT THÀNH PHỐ HỒ CHÍ MINH ***** LUẬN VĂN THẠC SĨ NGÔ BÁ VIỆT DÒ TÌM VẬT MỐC ĐỂ ĐIỀU KHIỂN XE LĂN ĐIỆN ĐẾN ĐÍCH DÙNG STEREO CAMERA NGÀNH: KỸ THUẬT ĐIỆN TỬ - 605270 Hướng dẫn khoa học: TS NGUYỄN THANH HẢI Tp Hồ Chí Minh, tháng 11/2013 LÝ LỊCH KHOA HỌC I LÝ LỊCH SƠ LƢỢC: Họ & tên: Ngô Bá Việt Giới tính: Nam Ngày, tháng, năm sinh: 18/04/1987 Nơi sinh: Bình Định Quê quán: Diễn Kỷ, Diễn Châu, Nghệ An Dân tộc: Kinh Địa liên lạc: 76/1 Dương Văn Cam, P.Linh Tây, Q.Thủ Đức, Tp.HCM Điện thoại quan: Di động: 0907.689.357 E-mail: ngobaviet@gmail.com II QUÁ TRÌNH ĐÀO TẠO:  Đại học: Hệ đào tạo: Chính qui Thời gian đào tạo từ 09/2005đến 01/2010 Nơi học (trường, thành phố): Đại học Sư Phạm Kỹ Thuật Tp.HCM Ngành học: Kỹ Thuật Điện – Điện Tử Tên đồ án, luận án môn thi tốt nghiệp: “NGHIÊN CỨU VÀ ỨNG DỤNG KIT ALTERA DE2 THIẾT KẾ CUỘC THI ĐƯỜNG LÊN ĐỈNH OLYMPIA” Ngày & nơi bảo vệ đồ án, luận án thi tốt nghiệp: Đại học Sư Phạm Kỹ Thuật Tp.HCM, tháng 01/2010 Người hướng dẫn: Ths Lê Minh Thành III QUÁ TRÌNH CÔNG TÁC CHUYÊN MÔN KỂ TỪ KHI TỐT NGHIỆP ĐẠI HỌC: Thời gian Nơi công tác Công việc đảm nhiệm 04/2010 – Cty TNHH GreyStone Data 10/2010 System Việt Nam 08/2011 – Trường Cao Đẳng Kỹ Thuật Cao đến Thắng Tp.HCM i Kỹ sư RD Giảng viên LỜI CAM ĐOAN Tôi cam đoan công trình nghiên cứu Các số liệu, kết nêu luận văn trung thực chưa công bố công trình khác Tp Hồ Chí Minh, ngày … tháng … năm 2013 (Ký tên ghi rõ họ tên) Ngô Bá Việt ii LỜI CẢM ƠN Xin chân thành gửi lời cảm ơn đến toàn thể quí Thầy Cô trường Đại học Sư Phạm Kỹ Thuật TP Hồ Chí Minh giảng dạy, hướng dẫn tạo điều kiện, môi trường học tập tốt cho Xin cảm ơn anh chị học viên lớp KĐT2011A ngành Kỹ thuật điện tử; anh chị chuyên viên phòng Lab A407, sinh viên Bộ môn Kỹ thuật Y Sinh trường Đại học Quốc tế, Đại học Quốc Gia TP Hồ Chí Minh chia sẻ, hỗ trợ, giúp đỡ suốt trình cộng tác nghiên cứu Xin gửi lời cảm ơn đến gia đình tôi, nguồn động viên tinh thần vô quý giá cho suốt thời gian học tập nghiên cứu Đặc biệt xin chân thành cảm ơn TS Nguyễn Thanh Hải tận tình hướng dẫn, theo sát tôi, giúp tháo gỡ khó khăn trình thực đề tài, từ lúc bắt đầu hoàn thành luận văn Một lần xin chân thành cảm ơn! Tp Hồ Chí Minh, ngày … tháng … năm 2013 (Ký tên ghi rõ họ tên) Ngô Bá Việt iii TÓM TẮT Một xe lăn điện cho người tàn tật nặng phát triển để hoạt động môi trường nhà, tự động tránh chướng ngại vật để di chuyển đến mục tiêu mong muốn cách sử dụng hệ thống Stereocopics camera Đề tài trình bày thuật toán điều khiển tự hành dựa điểm mốc đánh số theo thứ tự Thuật toán SURF áp dụng để nhận dạng vật mốc, đồng thời "Bumblebee" camera sử dụng để xác định tham số độ sâu hình ảnh môi trường phục vụ cho việc tính toán điều khiển Dựa thông tin này, xe lăn xác định vị trí cách sử dụng thuật toán hình học Kết cho thấy xe lăn tự động phát vật mốc để đạt mục tiêu mong muốn Điều cho thấy phương pháp đề xuất đáng tin cậy hiệu ABSTRACT An electrical wheelchair developed to operate in the indoor environments automatically avoids obstacles to move to the desired target for severely disabled people using a stereoscopic camera system This thesis presents a self-propelled control algorithm based on landmarks numbered in order A SURF algorithm was applied to identify the landmark position, at the same time the “Bumblebee” camera was used to determine the depth parameter of the environmental images for control calculation Based on this information, the wheelchair can locate where it is by using geometric projection algorithm The results showed that the wheelchair automatically detected the landmarks to reach the desired target This means that the proposed method is reliable and effective iv MỤC LỤC Trang tựa Trang Quyết định giao đề tài Lý lịch cá nhân i Lời cam đoan ii Lời cảm ơn .iii Tóm tắt iv Mục lục v Danh sách chữ viết tắt .viii Danh sách bảng ix Danh sách hình x Chƣơng 1: Tổng quan 01 1.1 Tổng quan lĩnh vực nghiên cứu 01 1.2 Các kết nghiên cứu nước công bố … 02 1.3 Mục tiêu đề tài… 04 1.4 Giới hạn đề tài… 04 1.5 Phương pháp nghiên cứu… 04 Chƣơng 2: Cơ sở lý thuyết 06 2.1 Thị giác máy tính 06 2.1.1 Giới thiệu 06 2.1.2 Hệ thống thị giác máy tính 07 2.1.3 Lĩnh vực ứng dụng thị giác máy tính 08 2.2 Không gian màu RGB phương pháp nhận dạng màu sắc sử dụng không gian màu RGB 08 2.2.1 Không gian màu RGB… 08 2.2.2 Phương pháp nhận dạng màu sắc sử dụng không gian màu RGB… 09 2.3 Không gian màu HSV phương pháp nhận dạng màu sắc sử dụng không gian màu HSV 11 v 2.3.1 Không gian màu HSV… 11 2.3.2 Phương pháp nhận dạng màu sắc sử dụng không gian màu HSV… 12 2.4 Các phương pháp nhận dạng vật thể 15 2.4.1 Phương pháp so khớp đặc điểm hình học 15 2.4.2 Phương pháp nhận dạng dựa diện mạo 15 2.4.3 Phương pháp nhận dạng dựa đặc điểm cục 16 2.5 Tầm nhìn lập thể… 18 2.5.1 Mô hình Camera… 19 2.5.2 Hệ thống Stereo camera… 20 2.5.3 Hình học Epipolar… 21 2.6 Các tính toán cho ảnh 3D… 22 2.6.1 Block matching… 22 2.6.2 Ảnh trái ảnh phải… 23 2.6.3 Tính toán Stereo Disparity… 24 2.6.4 Tính toán độ sâu ảnh 3D… 26 2.7 Thư viện OpenCV… 26 Chƣơng 3: Phƣơng pháp nhận dạng vật mốc … 28 3.1 Phương pháp SURF nhận dạng vật mốc 28 3.1.1 Phát điểm bật 29 3.1.2 Bộ mô tả đặc điểm… 30 3.1.3 So khớp mô tả… 32 3.2 Thuật toán Homography… 34 3.3 Phương pháp xác định tâm vật mốc… 37 Chƣơng 4: Tính toán điều khiển xe lăn điện… 38 4.1 Phương pháp tính toán khoảng cách góc lệch 38 4.1.1 Tính toán khoảng cách… 38 4.1.2 Tính toán góc lệch… 39 4.2 Xây dựng đồ khoảng cách 2D môi trường… 40 4.3 Thuật toán điều khiển xe lăn bám vật mốc… 42 4.3.1 Tính toán di chuyển xe lăn vật cản… 42 vi 4.3.2 Tính toán di chuyển xe lăn có vật cản… 46 4.3.2.1 Phát vật cản khoảng trống… 46 4.3.2.2 Tính toán tránh vật cản… 46 Chƣơng 5: Mô hình xe lăn điện kết thực nghiệm 51 5.1 Mô hình xe lăn điện… 51 5.2 Kết thực nghiệm… 54 5.2.1 Kết nhận dạng vật mốc… 54 5.2.2 Các tình thực hiện… 55 5.2.2.1 Xe lăn di chuyển đường vật cản… 56 5.2.2.2 Xe lăn di chuyển đường có vật cản… 57 Chƣơng 6: Kết luận 62 6.1 Kết đạt được… 62 6.2 Hạn chế đề tài… 62 6.3 Hướng phát triển đề tài… 62 Tài liệu tham khảo 63 Phụ lục… 66 vii DANH SÁCH CÁC CHỮ VIẾT TẮT AC Alternating Current BCI Brain – Computer Interface DC Direct Current DLL Dynamic Link Library EERUF Error Eliminating Rapid Ultrasonic Firing GPS Global Positioning System GPIO General - Purpose Input/Output HSV Hue – Saturation - Value LCD Liquid Crystal Display PCA Principal component analysis RGB Red – Green - Blue SAD Sum of Absolute Differences SVD Singular Value Decomposition SURF Speeded Up Robust Features VFH Vector Field Histogram VFF Virtual Force Field 3D Three - Dimensional 2D Two - Dimensional viii Phụ lục te = triclopsSetUniquenessValidation( triclops, );//0 te = triclopsSetUniquenessValidationThreshold( triclops, 1.18); // turn on sub-pixel interpolation te = triclopsSetSubpixelInterpolation( triclops, );//1 // make sure strict subpixel validation is on te = triclopsSetStrictSubpixelValidation( triclops, );//1 // turn on surface validation te = triclopsSetSurfaceValidation( triclops, );//100 te = triclopsSetSurfaceValidationSize( triclops, 175 );//200 te = triclopsSetSurfaceValidationDifference( triclops, 1.14 );// Jordan fixed from 0.5 - 0.90 // Set back forth to reduce noise in the readings te = triclopsSetBackForthValidation( triclops, ); // grab the image set de = digiclopsGrabImage( digiclops ); // grab the stereo data de = digiclopsExtractTriclopsInput( &stereoData ); digiclops, STEREO_IMAGE, // grab the color image data // (note: if you are using a B&W Digiclops, this will of course be // in B&W) de = digiclopsExtractTriclopsInput( &colorData ); digiclops, RIGHT_IMAGE, // preprocessing the images te = triclopsPreprocess( triclops, &stereoData ); // stereo processing te = triclopsStereo( triclops ) ; // retrieve the interpolated depth image from the context te = triclopsGetImage16( triclops, TriImg16_DISPARITY, TriCam_REFERENCE, &depthImage16 ); te = triclopsRectifyColorImage( triclops, TriCam_REFERENCE, &colorData, &colorImage ); int const ELEMENT_COUNT = depthImage16.ncols; float x_cur y_cur z_cur for ( { *x_cur, *y_cur, *z_cur; = new float[ELEMENT_COUNT];; = new float[ELEMENT_COUNT];; = new float[ELEMENT_COUNT];; i = 0; i < ELEMENT_COUNT; i++ ) z_cur[i] = 4; - 69 - Phụ lục } int cur_pos = 0; // determine the number of pixels spacing per row //Acquire data and save in x, y, and z (closest z for each column) pixelinc = depthImage16.rowinc/2; for ( i = 0, k = 0; i < depthImage16.nrows; i++ ) { row = depthImage16.data + i * pixelinc; for ( j = 0; j < depthImage16.ncols; j++, k++ ) { disparity = row[j]; // filter invalid points if (disparity=0.3)&&(y0)&&(z (round2(z))) { z_cur[j] = round2(z); x_cur[j] = round2(x); } } } } } for ( i = 0; i < ELEMENT_COUNT; i++ ) { xoutarray[i] = x_cur[i]; zoutarray[i] = z_cur[i]; } digiclopsStop( digiclops ); digiclopsDestroyContext( digiclops ); triclopsDestroyContext( triclops ); } Phụ lục 2: Chương trình nhận dạng vật mốc // EasyDLL5.cpp : Defines the entry point for the DLL application // #include "stdafx.h" extern "C" declspec(dllexport) float cdecl control(float &theta, float &status,float &depth, float &width,float &flat1,float &bientam); #include #include "triclops.h" #include "digiclops.h" - 70 - Phụ lục #include #include #include #include #include #define PI 3.14159265 #include #include using namespace std; // define whether to use approximate nearest-neighbor search #define USE_FLANN IplImage *image = 0; Double compareSURFDescriptors( const float* d1, const float* d2, double best, int length ) { double total_cost = 0; assert( length % == ); for( int i = 0; i < length; i += ) { double t0 = d1[i] - d2[i]; double t1 = d1[i+1] - d2[i+1]; double t2 = d1[i+2] - d2[i+2]; double t3 = d1[i+3] - d2[i+3]; total_cost += t0*t0 + t1*t1 + t2*t2 + t3*t3; if( total_cost > best ) break; } return total_cost; } Int naiveNearestNeighbor( const float* vec, int laplacian,const CvSeq* model_keypoints,const CvSeq* model_descriptors ) { int length = (int)(model_descriptors->elem_size/sizeof(float)); int i, neighbor = -1; double d, dist1 = 1e6, dist2 = 1e6; CvSeqReader reader, kreader; cvStartReadSeq( model_keypoints, &kreader, ); cvStartReadSeq( model_descriptors, &reader, ); for( i = 0; i < model_descriptors->total; i++ ) { const CvSURFPoint* kp = (const CvSURFPoint*)kreader.ptr; const float* mvec = (const float*)reader.ptr; CV_NEXT_SEQ_ELEM( kreader.seq->elem_size, kreader ); CV_NEXT_SEQ_ELEM( reader.seq->elem_size, reader ); if( laplacian != kp->laplacian ) continue; d = compareSURFDescriptors( vec, mvec, dist2, length ); if( d < dist1 ) { dist2 = dist1; - 71 - Phụ lục dist1 = d; neighbor = i; } else if ( d < dist2 ) dist2 = d; } if ( dist1 < 0.6*dist2 ) return neighbor; return -1; } Void findPairs( const CvSeq* objectKeypoints, const CvSeq*objectDescriptors,const CvSeq* imageKeypoints, const CvSeq* imageDescriptors, vector& ptpairs ) { int i; CvSeqReader reader, kreader; cvStartReadSeq( objectKeypoints, &kreader ); cvStartReadSeq( objectDescriptors, &reader ); ptpairs.clear(); for( i = 0; i < objectDescriptors->total; i++ ) { const CvSURFPoint* kp = (const CvSURFPoint*)kreader.ptr; const float* descriptor = (const float*)reader.ptr; CV_NEXT_SEQ_ELEM( kreader.seq->elem_size, kreader ); CV_NEXT_SEQ_ELEM( reader.seq->elem_size, reader ); int nearest_neighbor = naiveNearestNeighbor( descriptor, kp->laplacian, imageKeypoints, imageDescriptors ); if( nearest_neighbor >= ) { ptpairs.push_back(i); ptpairs.push_back(nearest_neighbor); } } } Void flannFindPairs( const CvSeq*, const CvSeq* objectDescriptors,const CvSeq*, const CvSeq* imageDescriptors, vector& ptpairs ) { int length = (int)(objectDescriptors>elem_size/sizeof(float)); cv::Mat m_object(objectDescriptors->total, length, CV_32F); cv::Mat m_image(imageDescriptors->total, length, CV_32F); // copy descriptors CvSeqReader obj_reader; float* obj_ptr = m_object.ptr(0); cvStartReadSeq( objectDescriptors, &obj_reader ); for(int i = 0; i < objectDescriptors->total; i++ ) { const float* descriptor = (const float*)obj_reader.ptr; CV_NEXT_SEQ_ELEM( obj_reader.seq->elem_size, obj_reader ); memcpy(obj_ptr, descriptor, length*sizeof(float)); obj_ptr += length; - 72 - Phụ lục } CvSeqReader img_reader; float* img_ptr = m_image.ptr(0); cvStartReadSeq( imageDescriptors, &img_reader ); for(int i = 0; i < imageDescriptors->total; i++ ) { const float* descriptor = (const float*)img_reader.ptr; CV_NEXT_SEQ_ELEM( img_reader.seq->elem_size, img_reader ); memcpy(img_ptr, descriptor, length*sizeof(float)); img_ptr += length; } // find nearest neighbors using FLANN cv::Mat m_indices(objectDescriptors->total, 2, CV_32S); cv::Mat m_dists(objectDescriptors->total, 2, CV_32F); cv::flann::Index flann_index(m_image, cv::flann::KDTreeIndexParams(4)); // using randomized kdtrees flann_index.knnSearch(m_object, m_indices, m_dists, 2, cv::flann::SearchParams(64) ); // maximum number of leafs checked int* indices_ptr = m_indices.ptr(0); float* dists_ptr = m_dists.ptr(0); for (int i=0;ipt; } = = _pt1 = cvMat(1, n, CV_32FC2, &pt1[0] ); _pt2 = cvMat(1, n, CV_32FC2, &pt2[0] ); if( !cvFindHomography( &_pt1, &_pt2, &_h, CV_RANSAC, )) return 0; for( i = 0; i < 4; i++ ) { double x = src_corners[i].x, y = src_corners[i].y; double Z = 1./(h[6]*x + h[7]*y + h[8]); double X = (h[0]*x + h[1]*y + h[2])*Z; double Y = (h[3]*x + h[4]*y + h[5])*Z; dst_corners[i] = cvPoint(cvRound(X), cvRound(Y)); } return 1; } void find_obj(IplImage* object,IplImage* &tcenter_obj_x,int &tcenter_obj_y ) { CvMemStorage* storage = cvCreateMemStorage(0); frame,int static CvScalar colors[] = { {{0,0,255}}, {{0,128,255}}, {{0,255,255}}, {{0,255,0}}, {{255,128,0}}, {{255,255,0}}, {{255,0,0}}, {{255,0,255}}, {{255,255,255}} }; IplImage* object_grey = cvCreateImage(cvGetSize(object), 8, 1); cvCvtColor( object, object_grey, CV_RGB2GRAY ); IplImage* image_grey = cvCreateImage(cvGetSize(frame), 8, 1); cvCvtColor( frame, image_grey, CV_RGB2GRAY ); IplImage* object_color = cvCreateImage(cvGetSize(object_grey), 8, 3); CvSeq *objectKeypoints = 0, *objectDescriptors = 0; CvSeq *imageKeypoints = 0, *imageDescriptors = 0; int i; CvSURFParams params = cvSURFParams(500, 1); - 74 - Phụ lục cvExtractSURF( object_grey, 0, &objectKeypoints, &objectDescriptors, storage, params ); cvExtractSURF( image_grey, 0, &imageKeypoints, &imageDescriptors, storage, params ); CvPoint src_corners[4] = {{0,0}, {object_grey->width,0}, {object_grey->width, object_grey->height}, {0, object_grey>height}}; CvPoint dst_corners[4]; #ifdef USE_FLANN //printf("Using approximate nearest neighbor search\n"); #endif if( locatePlanarObject( objectKeypoints, objectDescriptors, imageKeypoints, imageDescriptors, src_corners, dst_corners )) { for( i = 0; i < 4; i++ ) { CvPoint r1 = dst_corners[i%4]; CvPoint r2 = dst_corners[(i+1)%4]; cvLine( frame, cvPoint(r1.x, r1.y),cvPoint(r2.x, r2.y), colors[0],2 ); } CvPoint r11 = dst_corners[0]; CvPoint r33 = dst_corners[2]; // determine the center of obj CvPoint center1; center1.x = cvRound(r11.x + (r33.x - r11.x)/2); center1.y = cvRound(r11.y + (r33.y - r11.y)/2); cvCircle( frame, center1,5, CV_RGB(0,255,0), -1, 8, ); if ((center1.x >=0)&(center1.y>=0)&(center1.x pt.x); center.y = cvRound(r->pt.y); radius = cvRound(r->size*1.2/9.*2); cvCircle( object, center, radius, colors[0], 1, 8, ); } } declspec(dllexport) float cdecl control(float &theta, float &status,float &depth, float &width,float &flat1,float &bientam) { TriclopsContext triclops; TriclopsImage depthImage; TriclopsImage rightImageRaw; TriclopsInput inputData; DigiclopsContext digiclops; TriclopsROI *rois; int maxRois; int disparity; int i, j; float x, y, z; // open the Digiclops digiclopsCreateContext( &digiclops ); digiclopsInitialize( digiclops, ); // get the camera module configuration digiclopsGetTriclopsContextFromCamera( digiclops, &triclops ); // set the digiclops to deliver the stereo image only digiclopsSetImageTypes( digiclops, STEREO_IMAGE ); // set the Digiclops resolution // use 'HALF' resolution when you need faster throughput, especially for // color images // digiclopsSetImageResolution( digiclops, DIGICLOPS_HALF ); digiclopsSetImageResolution( digiclops, DIGICLOPS_FULL ); // start grabbing digiclopsStart( digiclops ); // set up some stereo parameters: // set to 320x240 output images //triclopsSetResolution( triclops, 240, 320 ); triclopsSetResolution( triclops, 480, 640 ); // set disparity range triclopsSetDisparity( triclops, 5, 60 ); // set invalid pixel value triclopsSetTextureValidationMapping( triclops, ); - 76 - Phụ lục triclopsSetUniquenessValidationMapping( triclops, ); unsigned char *row; // grab an image digiclopsGrabImage( digiclops ); digiclopsExtractTriclopsInput( digiclops, STEREO_IMAGE, &inputData ); // Preprocessing the images triclopsPreprocess( triclops, &inputData ); // stereo processing triclopsStereo( triclops ); // retrieve the depth image from the context triclopsGetImage( triclops, TriImg_DISPARITY, TriCam_REFERENCE, &depthImage ); digiclopsWritePPM( digiclops, RIGHT_IMAGE, "right.ppm" ); int m=0; float flag_vatcan; float *mang_Z = new float[m]; float *mang_X = new float[m]; float *mang_Row = new float[m]; float *mang_Col = new float[m]; for (i = 0; i= ) { triclopsRCD8ToXYZ( triclops, j, disparity, &x, &y, &z ); * i, } if ((z > 0.5)&&(z

Ngày đăng: 10/10/2016, 02:12

Mục lục

  • 1.pdf

    • Page 1

    • 2.pdf

      • SKC004095.pdf

        • 1 bia.pdf

        • 2 Luan van tot nghiep - Muc luc.pdf

        • 3 Luan van tot nghiep - C1.pdf

        • 4 Luan van tot nghiep - C2.pdf

        • 5 Luan van tot nghiep - C3.pdf

        • 6 Luan van tot nghiep - C4.pdf

        • 7 Luan van tot nghiep - C5.pdf

        • 8 Luan van tot nghiep - C6.pdf

        • 9 Luan van tot nghiep - Tai lieu.pdf

        • 10 Luan van tot nghiep - Phu luc.pdf

        • 11 BIA SAU.pdf

          • Page 1

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan