You need the following repo to make the code function
https://github.com/AndrewFromMelbourne/raspi2png
git clone https://github.com/AndrewFromMelbourne/raspi2png.git
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
wget https://gist.githubusercontent.com/matt-desmarais/c56f43bd4aeb51c9a574100ac6b40941/raw/99e7475a6957083bad26fcbad9b2f2290e6c25f9/picinpic.py
import cv2 import numpy import subprocess import time import datetime def get_file_name_pic(): # new return datetime.datetime.now().strftime("%Y-%m-%d_%H.%M.%S-combined.png") subprocess.Popen("./raspi2png", cwd='/home/pi/raspi2png') subprocess.Popen(["raspistill", "-t", "500", "-rot", "270", "-o", "/home/pi/camera.jpg"], shell=False) time.sleep(12) # 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 cv2.imwrite('/home/pi/test.png',img1) #generate filename for dropbox file name filename = get_file_name_pic() photofile = "/home/pi/Dropbox-Uploader/dropbox_uploader.sh 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.
Text editor powered by tinymce.