이미지에서 가장 밝은 픽셀을 찾는 데 필요한 미리 작성된 코드가 있습니다. 코드에 그림이로드되는 명령이 있습니다. 필요한 것은 웹캠으로 만든 라이브 비디오에서 가장 밝은 픽셀을 찾는 것입니다. 그래서 지금해야 할 일은 그림을로드하려는 선을 삭제하고 카메라에 액세스하기위한 선을 추가하는 것입니다. 나는 지금 몇 시간 동안 그렇게하려고 노력해 왔지만, 항상 오류 메시지를 받는다. 아무도 그 문제를 어떻게 해결할 수 있을지 모른다. 나는 블록 '그레이 스케일로 #로드 이미지 및 변환'을 전체를 삭제하려면 다음과 같은 라인을 추가 할코드 편집 : 사진 대신 내 웹캠에 액세스하는 방법
# import the necessary packages
import numpy as np
import argparse
import cv2
# construct the argument parse and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", help = "path to the image file")
ap.add_argument("-r", "--radius", type = int,
help = "radius of Gaussian blur; must be odd")
args = vars(ap.parse_args())
# load the image and convert it to grayscale
image = cv2.imread(args["image"])
orig = image.copy()
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# perform a naive attempt to find the (x, y) coordinates of
# the area of the image with the largest intensity value
(minVal, maxVal, minLoc, maxLoc) = cv2.minMaxLoc(gray)
cv2.circle(image, maxLoc, 5, (255, 0, 0), 2)
# display the results of the naive attempt
cv2.imshow("Naive", image)
# apply a Gaussian blur to the image then find the brightest
# region
gray = cv2.GaussianBlur(gray, (args["radius"], args["radius"]), 0)
(minVal, maxVal, minLoc, maxLoc) = cv2.minMaxLoc(gray)
image = orig.copy()
cv2.circle(image, maxLoc, args["radius"], (255, 0, 0), 2)
# display the results of our newly improved method
cv2.imshow("Robust", image)
cv2.waitKey(0)
을 :
Import SimpleCV
cam = SimpleCV.Camera()
img = cam.getImage().flipHorizontal().toGray()
img.show()
을 이것은 내가 편집하는 데 필요한 코드입니다 아무도 내가 새 오류 메시지를받지 않고 코드를 편집 할 수있는 방법을 알고 있습니까?