Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Converting Python to C++

I have the following opencv code in python and I would like to convert it to c++. I have already converted lines 1 and 2, but I got stuck on lines 3 and 4. Do any of you know how to convert those lines to c++.

contours, hierarchy = cv2.findContours(mask,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)
cnt = contours[0]
leftmost = tuple(cnt[cnt[:,:,0].argmin()][0])
rightmost = tuple(cnt[cnt[:,:,0].argmax()][0])
edge_left_x = leftmost[0]-320
edge_left_y = leftmost[1]-180
edge_right_x = rightmost[0]-320
edge_right_y = rightmost[1]-180