Take a photo with Pepper's camera How to display a picture taken on Pepper's chest display
Sening > Vision > Camera Actions > Take Picture
html
folder to save your photos in the app. *Explorer for Windows In Finder for Mac Open the folder of the app you are currently creating.
Create a new html
folder directly under the app folder.
Also, prepare a dummy file in the html
folder because anything is fine.
Return to choregraphe and when the dialog shown below is displayed Select "Yes to all".
html
folderhtml
folder created in 1-2. *Double-click the Take Picture box placed in 1-1. To add the code.
def onLoad(self):
self.bIsRunning = False
try:
self.photoCapture = ALProxy( "ALPhotoCapture" )
#Add from here
self.framemanager = ALProxy("ALFrameManager")
#Add up to here
def onInput_onStart(self):
#Add from here
import os
self.recordFolder = os.path.join(
self.framemanager.getBehaviorPath(self.behaviorId), "../html")
#Add up to here
if( self.bIsRunning ):
return
with this
Before change: (home directory) / recordings / cameras /
↓
After change: (Running app directory) / html /
It will be.
Open the Take Picture box settings Check the "File Name".
You can see that it is saved as (directory of the running app) /html/image(.jpg)
.
Multimedia > Tablet > Show Image
Open the Show Image box settings Enter the photo file name with the extension in "Image Url".
Run the app in Pepper and make sure you can take pictures and display it.
Double-click the Show Image box placed in 2-1. And add the code in two places.
def onInput_onStart(self):
#Additional code:from here
import time
#Additional code:So far
# We create TabletService here in order to avoid
# problems with connections and disconnections of the tablet during the life of the application
tabletService = self._getTabletService()
if tabletService:
try:
url = self.getParameter("ImageUrl")
if url == '':
self.logger.error("URL of the image is empty")
if not url.startswith('http'):
url = self._getAbsoluteUrl(url)
#Additional code:from here
url += "?" + str(time.time())
#Additional code:So far
tabletService.showImage(url)
except Exception as err:
self.logger.error("Error during ShowImage : %s " % err)
self.onStopped()
else:
self.logger.warning("No ALTabletService, can't display the image.")
self.onStopped()
Try running the app multiple times and see if the photo updates successfully.
*** (Caution) Show Image box (if the image display process is successful) ʻOnStopped` The output does not fire. *** ***
Therefore, the method to easily connect to the next process is as shown in the figure below.
If you want to erase the image from the display Fires the ʻonHideImage` input in the Show Image box.
Above: vulcan_tone1: There may be a smarter way to write I can't check the operation, so for the time being: baby_tone1:
Reference: Take an image with Pepper and display it on a tablet