[PYTHON] Take a photo with Pepper & display it on your chest display -Choregraphe 2.5.5 version-

Take a photo with Pepper's camera How to display a picture taken on Pepper's chest display


1. Take a photo

1-1. Place the Take Picture box

Sening > Vision > Camera Actions > Take Picture スクリーンショット 2019-12-25 21.59.11.png

1-2. Create html folder

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". スクリーンショット 2019-12-28 22.09.12.png

1-3. Save the photos you took to the html folder

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.

1-4. Check the photo file name

Open the Take Picture box settings Check the "File Name". スクリーンショット 2019-12-25 22.33.50.png

You can see that it is saved as (directory of the running app) /html/image(.jpg).


2. Show the photo on the chest display

2-1. Place the Show Image box

Multimedia > Tablet > Show Image スクリーンショット 2019-12-28 22.16.55.png

2-2. Specify the file name

Open the Show Image box settings Enter the photo file name with the extension in "Image Url". スクリーンショット 2019-12-28 22.18.50.png


3. Operation check

Run the app in Pepper and make sure you can take pictures and display it.


4. Make sure the image is updated even if you run the app multiple times

4-1. Add query parameters to the image URL

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()

4-2. Operation check

Try running the app multiple times and see if the photo updates successfully.


Bonus 1: Display the image and proceed to the next process

*** (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. スクリーンショット 2019-12-28 23.03.24.png


Bonus 2: Hide the image

If you want to erase the image from the display Fires the ʻonHideImage` input in the Show Image box. スクリーンショット 2019-12-28 23.14.26.png


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

Recommended Posts

Take a photo with Pepper & display it on your chest display -Choregraphe 2.5.5 version-
Take an image with Pepper and display it on your tablet
Make your cursor a photo of your choice on Linux