Ask Your Question

Revision history [back]

translate some python codes into c++

      contours, hierarchy = cv2.findContours(roiImg,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
      for i in contours:
        area = cv2.contourArea(i)
        moments = cv2.moments (i)

        if area>1500: 
            if moments['m00']!=0.0:
                if moments['m01']!=0.0:              
                    cx = int(moments['m10']/moments['m00'])         # cx = M10/M00
                    cy = int(moments['m01']/moments['m00'])         # cy = M01/M00
                    cv2.circle(frame,(cx,cy+350), 4, (255,0,0), -1)
                    cv2.circle(frame,(cx,cy+350), 8, (0,255,0), 0)

these codes is written by python , but I want to know how to write them in c++