2017-05-18 2 views
0
def drawRedRectangleAroundPlate(imgOriginalScene, licPlate): 

    p2fRectPoints = cv2.boxPoints(licPlate.rrLocationOfPlateInScene)   # get 4 vertices of rotated rect 

    cv2.line(imgOriginalScene, tuple(p2fRectPoints[0]), tuple(p2fRectPoints[1]), SCALAR_RED, 2)   # draw 4 red lines 
    cv2.line(imgOriginalScene, tuple(p2fRectPoints[1]), tuple(p2fRectPoints[2]), SCALAR_RED, 2) 
    cv2.line(imgOriginalScene, tuple(p2fRectPoints[2]), tuple(p2fRectPoints[3]), SCALAR_RED, 2) 
    cv2.line(imgOriginalScene, tuple(p2fRectPoints[3]), tuple(p2fRectPoints[0]), SCALAR_RED, 2) 
    # end function 

ich bin immer Fehler, wenn ich dies in Raspberry Pi laufen, dass "Integer-Argument bekam erwartet float""Integer-Argument erwartet bekam Float" beim Laufen in Raspberry Pi. Was kann die Lösung sein?

+1

Bearbeiten Sie Ihre Frage so die vollständige Zurückverfolgungs aufzunehmen. – iled

Antwort

0

Meine Vermutung jeder ist Ihr p2fRectPoints enthält float statt int Typ.
versuchen Sie dies:
def drawRedRectangleAroundPlate(imgOriginalScene, licPlate): # get 4 vertices of rotated rect p2fRectPoints = cv2.boxPoints(licPlate.rrLocationOfPlateInScene) # convert float arrays to int tuples for use with cv2.line() p0 = (int(p2fRectPoints[0][0]), int(p2fRectPoints[0][1])) p1 = (int(p2fRectPoints[1][0]), int(p2fRectPoints[1][1])) p2 = (int(p2fRectPoints[2][0]), int(p2fRectPoints[2][1])) p3 = (int(p2fRectPoints[3][0]), int(p2fRectPoints[3][1])) # draw 4 red lines cv2.line(imgOriginalScene, p0, p1, SCALAR_RED, 2) cv2.line(imgOriginalScene, p1, p2, SCALAR_RED, 2) cv2.line(imgOriginalScene, p2, p3, SCALAR_RED, 2) cv2.line(imgOriginalScene, p3, p0, SCALAR_RED, 2)

+0

Vielen Dank.! es funktionierte –