バウンディングボックスの中心点を表すドットをバウンディングボックスに描画しようとしています。中心点を計算しましたが、CMDでのみ出力され、この点が画像に表示されません。
Visual Studio 2010C++でOpenCV2.4.3を使用しています
for(int i= 0; i < boundRect.size(); i++ )
{
//BoundingBox Area
boundingBoxArea.clear();
boundingBoxArea.push_back(Point2f(boundRect[i].x, boundRect[i].y));
boundingBoxArea.push_back(Point2f(boundRect[i].x + boundRect[i].width, boundRect[i].y));
boundingBoxArea.push_back(Point2f(boundRect[i].x + boundRect[i].width, boundRect[i].y + boundRect[i].height));
boundingBoxArea.push_back(Point2f(boundRect[i].x, boundRect[i].y + boundRect[i].height));
double area0 = contourArea(boundingBoxArea);
cout << "area of bounding box no." << i << " = " << area0 << endl;
//Bounding Box Centroid
area0 = (boundRect[i].x + boundRect[i].width)/2, (boundRect[i].y + boundRect[i].height)/2;
cout<<"Rectangle " <<i<< " Centroid possition is at: " "=" <<area0<<endl;
cout<<""<<endl;
cout<<""<<endl;
}
上記は、私がうまく使用しているコードですが、バウンディングボックスの計算を担当する部分はごくわずかです。