Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Tip

GRABBER Video capture device

MACRO Macro

CAM Camera

MONITOR Monitor

Formats and functions

Format of events procedure for the Video capture device:

...

Code Block
DoReact("MONITOR","_id_","_command_"[,"_parameters_"]);

Examples

Examples of using events and reactions of the Video capture device object:

...

  1. Switch camera to the color mode and start recording from it when arming the first camera.

    Code Block
    OnEvent("CAM","1","ARM") //first camera is armed
    {
        DoReact("CAM","1","SETUP","color<1>"); // set color mode of camera
        DoReact("CAM","1","REC"); //record from the first camera
    }


  2. Arm the first camera when disabling the fifth camera.

    Code Block
    OnEvent("CAM","5","DETACH") // fifth camera is disabled
    {
        DoReact("CAM","1","ARM"); //first camera is armed
    }


  3. Use half of resources when recording from the first camera (it means, if four cameras are connected through the first video capture device than the first camera will record with speed of 6 FPS, and other three cameraswith speed of 2-2.5 FPS) if it is in the alarm state.

    Code Block
    OnEvent("CAM","1","MD_START") //first camera is in alarm state
    {
        DoReact("CAM","1","SETUP","rec_priority<2>"); // use half of resources when recording
    }


  4. Set maximum compression synchronously with the fourth microphone of audio card on the first camera when recording on disk from the first camera.

    Code Block
    OnEvent("CAM","1","REC") //first camera recording on disk
    {
        DoReact("CAM","1", "SETUP", "compression<5>, audio_type<OLXA_LINE>, audio_id<4>"); //first camera, maximum compression, synchronously with the forth microphone of audio card.


  5. Start recording from the first camera with minimum quality in black and white mode when it isn't alarmed.

    Code Block
    OnEvent("CAM","1","MD_STOP") // first camera stopped to be in alarm state
    {
        value = 5;
        DoReact("CAM", "1", "SETUP", "compression<" + value + ">,color<0>");
        //start recording from the first camera with minimum quality in the black and white mode.
    }


  6. Start recording from the first camera in the “rollback” mode when it is disarmed.

    Code Block
    OnEvent("CAM","1","DISARM")  //first camera is disarmed
    {
        DoReact("CAM","1","REC","rollback<1>");  // Start recording from the first camera in the "rollback" mode
    }


  7. Set new parameters of video signal when connecting the first camera.

    Code Block
    OnEvent("CAM","1","ATTACH") //first camera is connected
    {
        VIDEO_CANAL_ID = GETOBJECTPARAM("CAM","1","PARENT_ID"); // define ID of video channel to which the first camera belongs
        DoReact("GRABBER",VIDEO_CANAL_ID,"SETUP","chan<0>,mode<0>,resolution<1>,format<pal>"); //set new parameters of video channel
    }


  8. Start auto cruising on Camera 1 when Macro 2 is run.

    Code Block
    OnEvent ("MACRO","2","RUN")
    {
        DoReact("CAM","1","CRUISE_START","cruise_id<1>,action<CRUISE_START>,cam_id<1>");
    }
  9. There is a certain number of cameras (num). It is necessary to check the operation of motion detection on all cameras (can be used to check the performance of security sensors).
    To solve the problem, you can use the emulation of a linear character array (string), it means, the array of characters is filled in (in the example, it is the "N" character). Then, when the camera’s motion detection is triggered, the corresponding (to the camera ID) element of the array is changed (changed to "Y"). Thus, the output is a character array of "N" (the camera didn’t trigger) and "Y" (the camera triggered). The number of detections is counted and a message with the total number of cameras and the number of cameras that triggered is displayed. Start the check on Macro 1. Stop on Macro 2.
    Code Block
    OnInit()
    {
        run=0;
    }
     
    OnEvent("MACRO","1","RUN")
    {
        run=1; flag=""; num=8;
        for(i=1;i<str(num+1);i=str(i+1))
        {
            DoReact("CAM",i,"DISARM");
            DoReact("CAM",i,"REC_STOP");
            DoReact("CAM",i,"ARM");
            flag=flag+"N";
            if(i<num) {flag=flag+"|";}
        }
    }
     
    OnEvent("CAM",N,"MD_START")
    {
        if(run)
        {
            nn=str((N*2)-1);
            flag=strleft(flag,str(nn-1))+"Y"+strright(flag,str(((num*2)-1)-nn));
        }
    }
     
    OnEvent("MACRO","2","RUN")
    {
        run=0; fin=0;
        for(i=1;i<str(num+1);i=str(i+1))
        {
            tmp=extract_substr(flag,"|",str(i-1));
            if(strequal(tmp,"Y")) {fin=str(fin+1);}
            DoReact("CAM",i,"DISARM");
        }
        tmp="ВсегоAll:"+str(num)+" СработалоWorked:"+str(fin);
        rez=MessageBox("",tmp,0);
    }

  10. When an alarm occurs on camera 1, captions must be overlaid on the video image from this camera. When the alarm ends, captions about the end of the alarm must be overlaid on the video image.
    Code Block
    OnEvent("CAM","1","MD_START")
    {
        DoReact("CAM","1","CLEAR_SUBTITLES","title_id<1>"); //delete all captions from video image
        DoReact("CAM","1","ADD_SUBTITLES","command<Camera 1 Alarm " + time + "\r>,page<BEGIN>,title_id<1>");
        //the time parameter allows you to include the time of event registration in captions
    }
     
    OnEvent("CAM","1","MD_STOP")
    {
        DoReact("CAM","1","ADD_SUBTITLES","command<Camera 1 End of alarm " + time + "\r>,page<END>,title_id<1>");
    }
    Info
    titleNote

    When you use the page<BEGIN> and page<END> parameters, the corresponding fields in the captions database will be filled in, which will make it possible to search for data using the Captions search interface object.

...

  1. Play record from camera 1 on the monitor 4 with the specified date and time when running the first macro.

    Code Block
    OnEvent("MACRO","1","RUN")
    {
        DoReact("MONITOR","4","ARCH_FRAME_TIME","cam<1>,date<"+date+">,time<11:00:00>");
        DoReact("MONITOR","4","KEY_PRESSED","key<PLAY>");
    }


  2. Switch to the mode of video archive viewing on the first camera of monitor 4 when printing the frame from the first camera and then go on 10 frames further starting from the specified date and time.

    Code Block
    OnEvent("CAM", "1", "PRINT")
    {
        DoReact("MONITOR","4","ARCH_FRAME_TIME","cam<1>,date<"+date+">,time <11:00:00>");
        for(i=0;i<10;i=i+1)
        {
            DoReact ("MONITOR","4","KEY_PRESSED","key<FF>");
        }
    }


  3. Zoom in the video image on the monitor screen if camera is in the alarm state and reset it when alarm is finished.

    Code Block
    OnEvent("CAM","1","MD_START")
    {
        DoReact("MONITOR","1","KEY_PRESSED","key<ZOOM_IN>");
    }
     
    OnEvent("CAM", "1", "MD_STOP");
    {
        DoReact("MONITOR","1","KEY_PRESSED","key<ZOOM_OUT>");
    }


  4. Display the layout number one on the monitor screen when running a macro.

    Code Block
    OnEvent("MACRO","1","RUN")
    {
        DoReact("MONITOR","1","KEY_PRESSED","key<SELECT_LAYOUT>,number<1>");
    }


  5. Command of starting the video export from Camera 1 in the Monitor 1, starting from 24-10-14 17:10:38 and to 24-10-14 17:10:80 to the c:\aaa.avi file.
    Examples of export starting in three ways: using the IIDK (port 900 and 1030) and using script:
    1. IIDK (port 900)
      MONITOR|1|START_AVI_EXPORT|start<24-10-14 17:10:38>,finish<24-10-14 17:10:50>,avi_path<c:\aaa.avi>,cam<1>
    2. IIDK (port 1030)
      CORE||DO_REACT|source_type<MONITOR>,source_id<1>,action<START_AVI_EXPORT>,params<4>,param0_name<avi_path>,param0_val<c:\aaa.avi>,param1_name<cam>,param1_val<1>,param2_name<finish>,param2_val<24-10-14 17:10:50>,param3_name<start>,param3_val<24-10-14 17:10:38>
    3. Script (start on Macro 1)

      Code Block
      OnEvent("MACRO","1","RUN")
      {
          DoReact("CORE","","DO_REACT","source_type<MONITOR>,source_id<1>,action<START_AVI_EXPORT>,params<4>,param0_name<avi_path>,param0_val<c:\aaa.avi>,param1_name<cam>,param1_val<1>,param2_name<finish>,param2_val<24-10-14
       17:10:50>,param3_name<start>,param3_val<24-10-14 17:10:38");
      }


  6. When macro 1 is run, enable mouse PTZ control on Camera 4 at Monitor 10. Disable it on Macro 2.

    Code Block
    OnEvent("MACRO","1","RUN")
    {
        DoReact("MONITOR","10","CONTROL_TELEMETRY","cam<4>,on<1>");
    }
     
    OnEvent("MACRO","2","RUN")
    {
        DoReact("MONITOR","10","CONTROL_TELEMETRY","cam<4>,on<0>");
    }


  7. Display an active camera on an analog monitor.
    Code Block
    OnEvent ("MONITOR","1","ACTIVATE_CAM")
    {
        DoReact ("CAM",cam,"MUX1");
    }

  8. Display an alarmed camera in the one-fold mode.
    Code Block
    OnEvent ("CAM",N,"MD_START")
    {
        DoReact ("MONITOR","1","ACTIVATE_CAM","cam<"+N+">");
        DoReact ("MONITOR","1","KEY_PRESSED","key<SCREEN.1>");
    }

  9. An alarm monitor that always displays a video from the last alarmed camera.
    Code Block
    OnInit()
    {
        counter=0;
    }
     
    OnEvent("CAM",T,"MD_START")
    {
        if(strequal(counter,"0"))
        {
            DoReact("MONITOR","2","REMOVE_ALL");
            DoReact("MONITOR","2","ADD_SHOW","cam<"+T+">");
        }
        counter=str(counter+1);
    }
     
     
    OnEvent("CAM",M,"MD_STOP")
    {
        counter=str(counter-1);
        if(strequal(counter,"0"))
        {
            DoReact("MONITOR","2","ADD_SHOW","cam<"+M+">");
        }
    }
    
  10. When macro 1 is run, enable layout scrolling on all servers in the Video surveillance monitor (Monitor 1). When macro 2 is run, disable layout scrolling on all servers.
    Code Block
    languagebash
    if(Event.SourceType == "MACRO" && Event.SourceId=="1" && Event.Action=="RUN")
    {
        DoReactStr("MONITOR", "1","START_PAGING_LAYOUTS","");
    }
     
    if (Event.SourceType == "MACRO" && Event.SourceId == "2" && Event.Action == "RUN")
    {
        DoReactStr("MONITOR", "1", "STOP_PAGING_LAYOUTS","");
    }