So I am having a prewritten code for finding the brightest pixel in an Image - the code has commands in it which load a picture. What I need is to find the brightest pixel in a live video made with my webcame. So what I need to do now is to delete the lines which want to load the picture, and add lines to access the camera. I have been trying to do so for hours now, but I am always getting error messages, does anybody have an idea how to solve that? This is the code I need to edit:
# 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)
I want to delete the whole '# load the image and convert it to grayscale' block and want to add the following lines:
Import SimpleCV
cam = SimpleCV.Camera()
img = cam.getImage().flipHorizontal().toGray()
img.show()
Does anybody know how I can edit the code without getting new error messages?