You need the following repo to make the code function

git clone

You need this Python library

sudo apt-get install python-numpy

Now for the code you can get it with wget or copy and paste from below

import cv2
import numpy
import subprocess
import time
import datetime

def get_file_name_pic():  # new

subprocess.Popen("./raspi2png",  cwd='/home/pi/raspi2png')
subprocess.Popen(["raspistill", "-t", "500", "-rot", "270", "-o", "/home/pi/camera.jpg"], shell=False)

# Load image and screenshot
img1 = cv2.imread('/home/pi/camera.jpg')
img2 = cv2.imread('/home/pi/raspi2png/snapshot.png')   
rows,cols,channels = img2.shape
#top-left corner pic in pic
img1[0:rows, 0:cols ] = img2
#save combined picture 
#generate filename for dropbox file name
filename = get_file_name_pic()

photofile = "/home/pi/Dropbox-Uploader/ upload /home/pi/test.png /Apps/PiGlass/"+filename
#runs photofile dropbox upload
subprocess.Popen(photofile, shell=True)

When you run the program it will take a screenshot followed by a picture and combine the screenshot into the photo. Below is an example of a picture generated by the above code.

This guide was first published on May 17, 2018. It was last updated on Mar 08, 2024.

This page (Picture and Screenshot Combo Capability) was last updated on Mar 08, 2024.

Text editor powered by tinymce.