translate some python codes into c++

asked 2015-07-22 02:52:27 -0600

XD gravatar image
      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++

edit retag flag offensive close merge delete

Comments

berak gravatar imageberak ( 2015-07-22 03:02:37 -0600 )edit