Материал из for iRidium developers
Перейти к: навигация, поиск
Эта страница является переводом страницы Video API. Перевод выполнен на 100%.

Other languages:
English • ‎русский

IRidium API.Videos, cameras, images

Methods for creating and using links to images and video-streams. Ways of work with cameras of control panels.

Methods

IR.CreateImage

to create a dynamic image with a specified set of parameters. If you do not specify all image parameters, the missing parameters will be taken by default or retain the previous value. The created image is not assigned to graphic items. You can use it on different pages by addressing to it by its name. The name of the created image, unlike the other properties, cannot be changed

Syntax

IR.CreateImage(name, {image_properties});

input value description
name "Camera 1" type: string
the name of the dynamic image (camera)
image_properties Property: value type: object
the set of dinamic image properties
  • URI: the link to the image
  • Refresh: for images (snapshots), update frequency. For video-streams - 0
  • Demuxer: automatic or manual selection of the FFMPEG stream type (in the cases when the stream cannot be defined automatically). The empty field - automatic selection, mxg - for Mobotix cameras
  • Probe Size: 50000 (Kb) - the buffer of data in Kb that will be downloaded before playing the video. It is 5Mb by default (if you set 0). It can be decreased for low resolution cameras of slow connection, but the value less then 20000Kb is not recommended
  • Param: the string for indicating the RTSP transport type. Indicate tcp, if video from the camera cannot be played via the Internet or produces playback artifacts
  • Audio: to play audio-streams. It works with Mobotix (mxg) cameras
  • ScaleWidth, ScaleHeight: resolution of stream or image. If you want to show the image in original size, do not fill this properties
output
Object [object ImagePrototype] type: Object
an instance of a graphic object (image)


Sample

IR.AddListener(IR.EVENT_START,0, function()
{
   // Create image
   IR.CreateImage("Camera 1", {URI: "http://login:pass@host:port/file", 
                              Refresh: 0, 
                              Demuxer: '', 
                              ProbeSize: 0, 
                              Param: '', 
                              Audio: false, 
                              ScaleWidth: 640, 
                              ScaleHeight: 480
                              });
 
   // Get image
   var l_oImage = IR.GetImage("Camera 1");    
   IR.Log(l_oImage)        // [object ImagePrototype]
 
   // Get image properties
   IR.Log(l_oImage.URI)    // http://login:pass@host:port/file
 
   // Setup image (set image properties)
   l_oImage.URI = "http://login:pass@host:port/file";
   l_oImage.Refresh = 0;
   l_oImage.Demuxer = '';
   l_oImage.ProbeSize = 0;
   l_oImage.Param = '';
   l_oImage.Audio = false;
   l_oImage.ScaleWidth = 1024;
   l_oImage.ScaleHeight = 768;
 
   // Link image to Item
   IR.GetItem("Page 1").GetItem("Item 1").GetState(0).Image = IR.GetImage("Camera 1");
   IR.GetItem("Page 1").GetItem("Item 2").GetState(0).Image = l_oImage;
});

if the camera has been created in Project Gallery (not in Script), you can link it to the item this way:

IR.GetItem("Page 1").GetItem("Item 1").GetState(0).Image = "Сamera from Gallery (name)"

the type of video stream cannot be changed via camera properties. It means that if you made an HTTP camera (via Studio or JS) and Demuxer & ProbeSize settings of this camera wasn't filled it will not be possible to change this settings via camera properties in JS. You have to create a camera with all the needed properties to make it possible to change them. Or you have to create a camera every time from zero to change a stream type.


IR.GetImage

to obtain an image as an object. It allows you to refer to dynamic images created from scripts or in iRidium Studio, the usual way

Syntax

IR.GetImage(name);

input value description
name "Camera 1" type: string
the name of the dynamic image (camera)
output
Object [object ImagePrototype] type: Object
an instance of a graphic object (image)


Sample

IR.AddListener(IR.EVENT_START,0,function()
{
IR.CreateImage("Norway", {URI: "http://217.17.220.110:80/mjpg/video.mjpg", 
                           Refresh: 0, 
                           Demuxer: '', 
                           ProbeSize: 0, 
                           Param: '', 
                           Audio: false, 
                           ScaleWidth: 640, 
                           ScaleHeight: 480
                           });
 
IR.CreateImage("Screen", {URI: "http://cf2.imgobject.com/t/p/original/l74Tss1TW5a9r6rDbkBYaPbNzcp.jpg", 
                           Refresh: 60000, 
                           Demuxer: '', 
                           ProbeSize: 0, 
                           Param: '', 
                           Audio: false, 
                           ScaleWidth: 800, 
                           ScaleHeight: 600
                           });
 
var l_oImage = IR.GetImage("Norway"); 
 
IR.GetItem("Page 1").GetItem("Item 1").GetState(0).Image = l_oImage;
IR.GetItem("Page 1").GetItem("Item 2").GetState(0).Image = IR.GetImage("Screen");			
});

if the camera has been created in Project Gallery (not in Script), you can link it to the item this way:

IR.GetItem("Page 1").GetItem("Item 1").GetState(0).Image = "Сamera from Gallery (name)"




IR.Camera

to get video from the front or main camera of iOS, Android, Windows devices and display it on graphic items in the interface. To use the function, the camera must be activated with the help of the IR.Camera method with settings and assigned to a graphic item in the project

Syntax

IR.Camera(action, <type>, <resolution>)

input value description
action IR.CAMERA_RECORD type: object
actions with video-streams:
  • IR.CAMERA_RECORD - to get video (type and resolution are required)
  • IR.CAMERA_STOP - to stop the video (without parameters)
  • IR.CAMERA_TOGGLE - to switch from the front to the main camera and back (type and resolution are not required)
  • IR.CAMERA_ROTATE - to rotate the image be the angle specified in the type field
  • IR.CAMERA_FLIP_VERTICAL - to flip the image vertically (true/false in the type field)
  • IR.CAMERA_FLIP_HORIZONTAL - to flip the image horizontally (true/false in the type field)
type IR.CAMERA_FRONT type: object
for IR.CAMERA_RECORD:
  • IR.CAMERA_BACK video from the main camera
  • IR.CAMERA_FRONT video from the front camera

for IR.CAMERA_ROTATE - the angle of rotation in degrees
for IR.CAMERA_FLIP_VERTICAL and IR.CAMERA_FLIP_HORIZONTAL - true/false, depending on the need of the flip

resolution IR.CAMERA_RESOLUTION_LOW type: object
indicate for IR.CAMERA_RECORD:
  • IR.CAMERA_RESOLUTION_LOW - low resolution
  • IR.CAMERA_RESOLUTION_MEDIUM - medium resolution
  • IR.CAMERA_RESOLUTION_HIGH - high resolution
output

-


Sample

// link camera to GUI item
IR.GetPopup("Page 1").GetItem("Item 1").GetState(0).Image = "ir_camera://";
 
// start record
IR.Camera(IR.CAMERA_RECORD, IR.CAMERA_FRONT, IR.CAMERA_RESOLUTION_MEDIUM);
 
// stop record
IR.Camera(IR.CAMERA_STOP);
 
// toggle camera
IR.Camera(IR.CAMERA_TOGGLE);
 
// rotate to angle
IR.Camera(IR.CAMERA_ROTATE, 270);
 
// flip horizontal
IR.Camera(IR.CAMERA_FLIP_HORIZONTAL, true);
 
// flip vertical
IR.Camera(IR.CAMERA_FLIP_VERTICAL, true);

to output video from the device camera on a graphic item, write "ir_camera://" in the graphic item property .Image, as shown in the example above
if you are using the SIP protocol for sending and receiving SIP video, write the incoming video-stream as "sip_image://" in the graphic item property .Image. See more in SIP.