java - How to Translate contour to the center of image in openCV? -



java - How to Translate contour to the center of image in openCV? -

i working on image processing project in android. task extract object , translate center of image can extract features easily. have extracted object, want translate center of image , rotate it, align horizontally on image.

i using opencv image processing in android. help highly appreciated. thanks

i suggest next technique..

vector<point>contour -- opencv contours vector of points. can translate them distance want. in c++ next translate contour

void shifcontour(vector<point>& contour, int x, int y) { (size_t i=0; i<contour.size(); i++) { contour[i].x += x; contour[i].y += y; } }

to find xand y, can utilize difference between centre of image , centre of contour. can utilize fitellipse calculate centre of contour. give rough approximation centre of contour. angle in contour directed..

(x_centre,y_centre),(majoraxis,minoraxis),angle = cv2.fitellipse(contour)

now contour beingness translated. next have rotate it, align horizontally. can utilize affine tranformation provided opencv rotate image specified angle.

http://docs.opencv.org/doc/tutorials/imgproc/imgtrans/warp_affine/warp_affine.html

hope helps.

java android opencv

Comments

Popular posts from this blog

python - How to add an model instance to a django queryset? -

Using Android Volley to post an array to PHP -

angularjs - No 'Access-Control-Allow-Origin' error from local domain to public API -