my purpose is using pi camera, capture picture of qr code (till here I already done), and align the picture on one platform to compare them are printed well.
so far I can capture the picture and save it on rasberry destop
environment: raspberrypi 4 Model B 32 bit, linux 5.15.61-v8; execute python3 script; logitech USB camera lens ; run in virtual environment
- below is the cool python script can capture picture, and save on destop
import cv2
import time
cap = cv2.VideoCapture(0) # video capture source camera (Here webcam of laptop)
ret,frame = cap.read() # return a single frame in variable `frame`
# run 60 sec x 4 min
time_end = time.time() + 60*4
while time.time() < time_end:
while(True):
cv2.imshow('img1',frame) #display the captured image
if cv2.waitKey(60) & 0xFF == ord('y'): #save on pressing 'y'
# put the file path you like
cv2.imwrite('/home/sam/Desktop/pic.png',frame)
cv2.destroyAllWindows()
break
cap.release()
break
And how can I make the picture align like below example, so that I can compare each qr code check there are correct?
now I can add two picture together as format 1 x 2
from picamera import PiCamera
import time
from PIL import Image
#Read the two images
image1 = Image.open('/home/joy/Desktop/pic.png')
image1.show()
image2 = Image.open('/home/joy/Desktop/pic_02.png')
image2.show()
#resize, first image
image1 = image1.resize((426, 240))
image2 = image2.resize((426, 240))
image1_size = image1.size
image2_size = image2.size
new_image = Image.new('RGB',(2*image1_size[0], image1_size[1]), (250,250,250))
new_image.paste(image1,(0,0))
new_image.paste(image2,(image1_size[0],0))
new_image.save("/home/joy/Desktop/pic_final.png","PNG")
new_image.show()
just not sure how can layout as 3x3 or 5x10