java - How to convert this code into javacv? -
i had went through many tutorials , guide lines , able convert part of it. don't know how convert last line in javacv. please can 1 me convert code in javacv?
img = cv2.imread('sofud.jpg') gray = cv2.cvtcolor(img,cv2.color_bgr2gray) ret,thresh = cv2.threshold(gray,127,255,1) contours,hierarchy = cv2.findcontours(thresh,cv2.retr_list,cv2.chain_approx_simple) cnt in contours: x,y,w,h = cv2.boundingrect(cnt) if 10 < w/float(h) or w/float(h) < 0.1: cv2.rectangle(img,(x,y),(x+w,y+h),(0,0,255),2)
you can use last line in java cv:
opencv_core.cvrectangle(image, opencv_core.cvpoint(m,n), opencv_core.cvpoint(i,j), opencv_core.cvscalar(0,0,255,0), thickness, 8, 0);
where parameters mean:
opencv_core.cvrectangle(cvarr* img, cvpoint , cvpoint, cvscalar color, int thickness=1, int linetype=8, int shift=0)
and @ link more information.
edit:
this example of finding contours:
cvfindcontours(grayimage, memory, contours, sizeof(cvcontour.class) , cv_retr_ccomp, cv_chain_approx_simple, cvpoint(0,0));
where parameter mean:
cvfindcontours(cvarr* image, cvmemstorage* storage, cvseq** first_contour, int header_size=sizeof(cvcontour), int mode=cv_retr_list, int method=cv_chain_approx_simple, cvpoint offset=cvpoint(0,0) )
for more information on parameters, take @ link, under findcontours
section.
you can use cvdrawcontours
function, draw contours in same way have used cvfindcontours
function.
take @ link. different post on website in have explained use of finding contours in blob detection.
hope helps.
Comments
Post a Comment