Camera
This documentation outlines basic camera functionalities, including changing the camera direction, taking snapshots, and displaying photos.
Change the Camera Direction
Rotate photo clockwise by 90 degree
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"Camera_rotatePhoto\" disabled=\"true\" x=\"158\" y=\"292\"><field name=\"direction\">RotationDirection.Clockwise</field><field name=\"degree\">RotationDegree.Ninety</field></block></xml>"}
This is used to change the direction of the image or photo.
Parameters: Image
- clockwise (Default)/anticlockwise
- 90 (Default)/180
Output: Image
Sample code:
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>photo1</variable></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">photo1</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Camera_takePhoto\"/></value><next><block type=\"Camera_showPhoto\"><value name=\"photo\"><block type=\"variables_get\"><field name=\"VAR\">photo1</field></block></value><next><block type=\"Camera_showPhoto\"><value name=\"photo\"><block type=\"Camera_rotatePhoto\"><field name=\"direction\">RotationDirection.Clockwise</field><field name=\"degree\">RotationDegree.Ninety</field><value name=\"photo\"><block type=\"variables_get\"><field name=\"VAR\">photo1</field></block></value></block></value></block></next></block></next></block></statement></block></xml>"}
The output:
Snapshot
Take Photo
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>photo1</variable></variables><block type=\"Camera_takePhoto\" disabled=\"true\" x=\"158\" y=\"293\"/></xml>"}
This is used to take the photo from the camera.
Parameters: N/A
Output: Image
Sample code:
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"Camera_showPhoto\"><value name=\"photo\"><block type=\"Camera_takePhoto\"/></value></block></statement></block></xml>"}
The output:
Display the Photo
Show Photo
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"Camera_showPhoto\" disabled=\"true\" x=\"23\" y=\"202\"/></xml>"}
This is used to show the photo from the image or camera.
Parameters: Image
Output: Image
Sample code:
{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"Camera_showPhoto\"><value name=\"photo\"><block type=\"Resources_getPhotoByURL\"><value name=\"url\"><shadow type=\"text\"><field name=\"TEXT\">https://www.magicubedu.com/una/AI1/2.jpg</field></shadow></value></block></value></block></statement></block></xml>"}
The output:
Table of Content