Successfully exports the RGB values of all pixels in the ROI

This commit is contained in:
Loic Delattre 2023-02-02 19:49:43 +01:00
parent 2c28812460
commit 67d723ae41
1 changed files with 7 additions and 20 deletions

View File

@ -11,7 +11,7 @@ read_img = cv2.imread(image)
#cv2.waitKey(0)
def auto_detect(img):
def RGB_dataframe(img):
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.3, 5)
@ -50,17 +50,15 @@ def auto_detect(img):
y1 = y + fy - 150
y2 = y + fy - 20
return x1, x2, y1, y2
imRGB = img[y1:y2, x1:x2]
#cv2.imshow('img',imRGB)
#cv2.waitKey(0)
def RGB_dataframe(image):
#dimensions = image.shape
#print(dimensions)
size_list = list(image.shape[:2])
size_list = list(imRGB.shape[:2])
pixel_values = []
for i in range(0, size_list[0]):
for j in range(0, size_list[1]):
k = image[i,j]
k = imRGB[i,j]
pixel_values.append(k)
fields = ['R', 'G', 'B']
with open('RGB_data.csv', 'w', newline="") as f:
@ -69,15 +67,4 @@ def RGB_dataframe(image):
write.writerows(pixel_values)
return
out_data = auto_detect(read_img)
x1 = out_data[0]
x2 = out_data[1]
y1 = out_data[2]
y2 = out_data[3]
image = "frames/frame1.jpg"
read_img = cv2.imread(image)
imRGB = read_img[y1:y2, x1:x2]
#cv2.imshow('img',imRGB)
#cv2.waitKey(0)
RGB_dataframe(imRGB)
RGB_dataframe(read_img)