1
2
3
4 from RobotInstance import RobotInstance
5
7 '''
8 Class that represents the Raspberry Pi camera.
9 '''
10
21
23 robot.sendCommand(self.device + ".create")
24 self.robot = robot
25
27 '''
28 Takes a camera picture with given picture size and stores is
29 in JPEG format on the remote device.
30 The picture resolution is width x height (max: 5 MPix)
31 @param width: the width of the picture in pixels (max: 2592)
32 @param height: the height of the picture in pixels (max: 1944)
33 @param filename: a valid filename in the remote file space, e.g. /home/pi/shot1.jpg
34 '''
35 self._checkRobot()
36 filename = filename.replace(".", "`")
37 self.robot.sendCommand(self.device + ".captureAndSave."
38 + str(width) + "." + str(height) + "." + filename)
39
41 '''
42 Performs a camera capture with given resolution width x height in pixels.
43 The camera picture is hold in memory on the remote device and transferred in JPEG format
44 to the local device.
45 @return: Binary data holding the jpeg formated image (as string).
46 @rtype: str
47 '''
48 self._checkRobot()
49 self.robot.isBinaryReply = True
50 return self.robot.sendCommand(self.device + ".captureJPEG." + str(width) + "." + str(height))
51
53 '''
54 Writes the given string data into a binary file.
55 @param data: the image data (as string) to store
56 @param filename: a valid filename in the local file space
57 '''
58 file = open(filename, "wb")
59 file.write(data)
60 file.close()
61
65