看板 C_and_CPP 關於我們 聯絡資訊
開發平台(Platform): VC++2012 額外使用到的函數庫(Library Used): OpenMP, OpenCV 問題(Question): 我已使用OepnCV將2D點群組成三角網 然後我想要,當我輸入一組點坐標時,可以算出落在第幾號三角網中 在這一部分我想使用OpenMp加速搜尋 餵入的資料(Input): 2D的平面點坐標 預期的正確結果(Expected Output): 可回傳輸入點的坐落三角網編號 錯誤結果(Wrong Output): 可以compiler,但無法run 程式碼(Code):(請善用置底文網頁, 記得排版) void Find_Triangle_id(int &output_id,Point2f pt,vector<Vec6f> triangle_data, vector<Point2f> boundary) { vector <Point2f> tri_pt(3); Vec6f tri; bool good_triangle; output_id = -1; //如果回傳-1 表示沒有找 cout<<"start: "<<endl; if(pointPolygonTest(boundary,pt,false)>0){ //如果有在邊界範圍內 #pragma omp parallel for private(tri_pt,tri,good_triangle) for(int tri_id = 0;tri_id<triangle_data.size(); tri_id++){ good_triangle = true; tri = triangle_data[tri_id]; tri_pt[0] = Point2f(tri[0],tri[1]); tri_pt[1] = Point2f(tri[2],tri[3]); tri_pt[2] = Point2f(tri[4],tri[5]); for(char i=0;i<3;i++){ // 確認三角網的3個點都在範圍內 if(pointPolygonTest(boundary,tri_pt[i],false)<0){ good_triangle = false;} } if(good_triangle){ // 如果input點坐標在三角網內,記錄此三角網編號 if(pointPolygonTest(tri_pt,pt,false)>0){ output_id = tri_id;} } } } 補充說明(Supplement): vector<Vec6f> triangle_data已經從subdiv.getTriangleList(triangle_data)取得 vector<Point2f> boundary是我自己輸入設定的4角邊界坐標 函請有經驗的高手幫我隔空抓個蟲 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 116.86.232.153 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1464793170.A.28B.html ※ 編輯: jason77623 (137.132.133.87), 06/02/2016 15:17:59