Documentation

Una is developed by Una Technologies Limited

All rights reserved

© 2022 Una Technologies Limited

Print

Getting the Specified Camera

Get camera

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"Camera_getCamera\"><value name=\"deviceId\"><shadow type=\"text\"><field name=\"TEXT\"/></shadow></value></block></xml>"}
				
			

This block is used to get the camera by inputting the camera’s id inside this block.

Parameters: String
Output: Screen Item
Sample code:

The variable will get the camera.

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"variables_set\"><field name=\"VAR\">getCamera</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Camera_getCamera\"><value name=\"deviceId\"><shadow type=\"text\"><field name=\"TEXT\">7e2b0995f8a6d9df2958ed69edbb3757cfd0680da8b2fd6a0bcbb8b54987bb9d</field></shadow></value></block></value></block></xml>"}
				
			
				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>mainLayout</variable><variable>mainScreen</variable><variable>cameraLayout</variable><variable>cameraControl</variable><variable>deviceId</variable><variable>getCamera</variable></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><block type=\"Camera_enableCameraFeature\"><value name=\"enable\"><shadow type=\"logic_boolean\"><field name=\"BOOL\">TRUE</field></shadow></value><next><block type=\"variables_set\"><field name=\"VAR\">cameraLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">cameraControl</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Camera_getCameraControl\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">deviceId</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"0\" _input_init=\"false\"></mutation></block></value><next><block type=\"Control_OptionList_setMultiple\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">cameraControl</field></block></value><value name=\"isMultiple\"><shadow type=\"logic_boolean\"><field name=\"BOOL\">TRUE</field></shadow></value><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">cameraLayout</field></block></value><value name=\"item\"><block type=\"variables_get\"><field name=\"VAR\">cameraControl</field></block></value><next><block type=\"Control_TextBlock_setContent\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">deviceId</field></block></value><value name=\"content\"><block type=\"Camera_Camera_getDeviceId\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">getCamera</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">getCamera</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Camera_getCamera\"><value name=\"deviceId\"><shadow type=\"text\"><field name=\"TEXT\">7e2b0995f8a6d9df2958ed69edbb3757cfd0680da8b2fd6a0bcbb8b54987bb9d</field></shadow></value></block></value><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">cameraLayout</field></block></value><value name=\"item\"><block type=\"variables_get\"><field name=\"VAR\">deviceId</field></block></value><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">cameraLayout</field></block></value><value name=\"item\"><block type=\"variables_get\"><field name=\"VAR\">getCamera</field></block></value><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"variables_get\"><field name=\"VAR\">cameraLayout</field></block></value></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block></xml>"}
				
			

When selecting USB2.0 HD UVC WebCam (13d3:56a8), the output:

The camera id is: 7e2b0995f8a6d9df2958ed69edbb3757cfd0680da8b2fd6a0bcbb8b54987bb9d

Previous Check Whether the Specified Camera is Included
Next Displaying Camera ID