뭐가 잘못 됬는지 알려주세요 제발 파이썬 입니다 진하게 칠한부분이 오류라는데...

2021-04-04 (일) 01:38:25 2,664

import numpy as np
import cv2

cap = cv2.VideoCapture(1)

ret,img = cap.read()


cv2.line(img,(0,0),(img.shape[1]-2, img.shape[0]-2), (255,0,255), 2)
cv2.rectangle(img,(1,1),(img.shape[1]-2,img.shape[0]-2),(255,0,0), 2)
cv2.circle(img,(int(img.shape[1]/2),int(img.shpe[0]/2)), 100, (0,255,0), 2)
cv2.eplipse(img, (256,256), (100,50),0,0, 360, (0,255,255),0)

pts = np.array([[10,5],[200,300],[400, 300],[50,10]],np.int32
pts = pts.reshape((-1,1,2))
cv2.polylines(img,[pts], True, (0,255,255))


font = cv2.FONT_HERSHEY_SIMPLEX
cv2.putText(img,'Welcome Opencv and IP',(10,200),font,1,(255,255,0),2,cv2.LINE_AA)

cv2.imshow('test',img)
cv2.waitKey(0)
cap.release()
cv2.destroyAllWIndow()

|

답변 2개 / 댓글 1개

안녕하세요?

작성하신 스크립트에서 일부를 살짝 수정하였더니 잘 작동하네요~ ^-^

그럼 좋은 주말 되세요 :)

Copy
import numpy as np

import cv2

 

cap = cv2.VideoCapture(1)

ret, img = cap.read()

 

cv2.line(img,(0,0),(img.shape[1]-2, img.shape[0]-2), (255,0,255), 2)

cv2.rectangle(img,(1,1),(img.shape[1]-2,img.shape[0]-2),(255,0,0), 2)

cv2.circle(img,(int(img.shape[1]/2),int(img.shape[0]/2)), 100, (0,255,0), 2) # sh'a'pe 스펠링을 수정했습니다.

cv2.ellipse(img, (256,256), (100,50),0,0, 360, (0,255,255),0) # e'l'lipse 스펠링을 수정했습니다.

 

pts = np.array([[10,5],[200,300],[400, 300],[50,10]],np.int32) # 괄호가 빠졌습니다.

pts = pts.reshape((-1,1,2))

cv2.polylines(img,[pts], True, (0,255,255))

 

pts = np.array([[10,5],[200,300],[400, 300],[50,10]],np.int32)

pts = pts.reshape((-1,1,2))

cv2.polylines(img,[pts], True, (0,255,255))

 

font = cv2.FONT_HERSHEY_SIMPLEX

cv2.putText(img,'Welcome Opencv and IP',(10,200),font,1,(255,255,0),2,cv2.LINE_AA)

cv2.imshow('test',img)

cv2.waitKey(0)

cap.release()

cv2.destroyAllWIndow()

답변에 대한 댓글 1개

2021-06-12 (토) 00:07:07
늦었지만 감사합니다
2021-04-04 (일) 08:42:30

바로 윗줄 array에서 괄호가 빠진 거 아닐까요?

답변을 작성하려면 로그인이 필요합니다.