When to use video presence tests? Go to top

Video presence tests are suitable for use in cases when we need to verify that some video content is properly decoded, that the channel is changed correctly, that the video is present on the DUT (Device Under Test) output (e.g. HDMI or SCART), etc.

 

Typical test sequence Go to top

Figure 1. Typical steps in video presence tests

As shown in the Figure 1, a typical video presence test case is performed in 3 steps. We will focus only to related parts of the test script for this scenario that we are explaining; the rest of the code has already been explained in Anatomy of a test script section. A detailed explanation of the API functions used in this example can be seen in the API section.

In the first step, we select the grabber input video source (e.g. SCART or HDMI) that is connected to the DUT (Device Under Test) video output. In the second step, we navigate the DUT to the desired state (menu option). In the final step, we use the video grabber to execute a certain action concerning video presence (check the video output status, record video, record consecutive video snapshots, etc), analyze the output from the video grabber device and decide on the outcome of the test.

 

1. Select input source Go to top

We select the grabber input video source (e.g. SCART or HDMI) that is connected to the DUT video output.

TEST_CREATION_API.grabber_start_video_source(TEST_CREATION_API.VideoInterface.HDMI1)
 

2. Navigate Go to top

In the second step, we navigate the DUT to the desired state (menu option).

## Zapping time in digital systems isn't a constant category,
# but there are always some values defined as a max zapping duration,
# time in which the zapping will be completed. Here we define max zapping time in seconds.
MAX_ZAP_TIME_DURATION = 6

## Tune to scanned channel
TEST_CREATION_API.send_ir_rc_command("[CH_1]")
time.sleep(MAX_ZAP_TIME_DURATION)

Note here that the presume that the channel 1 is available, that the channels are scanned and are available in the channel list.

Macro [CH_1] used here for navigation is defined in the RemoteController.ini configuration file. It represents an RC sequence of different RC keys to be sent to the DUT in order to navigate to the desired state. Every RC key used in macros is represented by its name (names are created using the RC Capture application), number of times that RC key should be pressed and the time delay in ms after every press. An example of this RC Key follows:

[CH_1] "1 1 1000"
 

3. Video presence check Go to top

In the final step, we use the video grabber to execute a certain action concerning video presence (check the video output status, record video, record consecutive video snapshots, etc), analyze the output from the video grabber device and decide on the outcome of the test.

 
Checking signal output status Go to top

In this case, we check if the video is present on the video output that we have previously selected (HDMI1 in our case).

## Check if video signal is present on HDMI interface
if (TEST_CREATION_API.is_signal_present_on_video_source()):
    ## Set test result variable to PASS if video signal is present
    test_result = "PASS"
else:
    ## Write message to log file if video signal is not present and continue execution
    TEST_CREATION_API.write_log_to_file("Video signal is not present on HDMI interface")
 
Waiting for the non-black picture after zapping Go to top

In this case we wait to get a non-black picture with the given timeout.

## Time until comparing is finished (in seconds)
WAIT_TIMEOUT = 10

## Check if captured picture is different from referent one.
# Macro [FULL_SCREEN] is defined in RT-AV101.ini file.
# Macro [FULL_SCREEN] is used to monitor precise region in the picture
# that will be different as that region on referent picture.
if (TEST_CREATION_API.wait_for_picture("black_screen.bmp", "[FULL_SCREEN]", WAIT_TIMEOUT, TEST_CREATION_API.DEFAULT_HDMI_VIDEO_THRESHOLD, TEST_CREATION_API.WaitForPicture.DIFFERENT)):
        test_result = "PASS"
else:
    ## Write message to log file if the black screen is still displayed after WAIT_TIMEOUT and continue execution
    TEST_CREATION_API.write_log_to_file("Home menu is not displayed correctly")

Note here that the wait_for_picture() function receives the [FULL_SCREEN] macro as an input argument, which is defined in the RT-AV101.ini configuration file. That macro is used to monitor a precise region in the picture that will be the same as that region on the referent picture. It has the following format:

[FULL_SCREEN] "compare_left x_start" "compare_top y_start" "compare_right x_end" "compare_bottom y_end"

For the exact coordinates that should be defined here, the tool called Reference Creator can be used.

You can also note that we have used the wait_for_picture() function for detecting the absence of the black screen over a period of time, just by placing the image with all the black pixels inside (image “black_screen.bmp”) as a referent one.

 
Checking if the consecutive images are different Go to top

Here we capture SNAPSHOTS_NUMBER images, and check if they are different. The files will be recorded in the BMP format and stored in the current test execution folder. The file name here (“zapping”) presents only a prefix, because the picture names will be in the following format: zapping_0_0.bmp…zapping_0_N.bmp, where N = SNAPSHOTS_NUMBER.

## Number of snapshots to grab
SNAPSHOTS_NUMBER = 10
## Grab multiple pictures (SNAPSHOTS_NUMBER)
# The file will be recorded in BMP format, so the file name extension is excluded here.
TEST_CREATION_API.grab_picture("zapping", SNAPSHOTS_NUMBER)

## Compare multiple pictures with one referent picture
# or with first of test pictures if referent is not set.
# To use referent picture add name of picture as fourth parameter.
# To use custom threshold for matching
# referent and test picture set fifth parameter as integer from 0 to 100.
# If region is set only region of interest is compared.
# If region is not set whole pictures are compared by default.
# Macro [FULL_SCREEN] is defined in PictureAlgorithm.ini file.
# The file name here presents only a prefix,
# because the picture names should be in format:
# filename_0_0.bmp...filename_0_N.bmp
if not (TEST_CREATION_API.compare_multiple_pictures("zapping", "[FULL_SCREEN]", SNAPSHOTS_NUMBER)):
    ## Set test result variable to PASS if pictures are the different
    test_result = "PASS"
else:
    ## Write message to log file if the pictures are the same.
    TEST_CREATION_API.write_log_to_file("Images after zapping are the same.")

Note here that the compare_multiple_pictures() function receives [FULL_SCREEN] macro as an input argument, which is defined in the PictureAlgorithm.ini configuration file. This macro is used to check precise region in the picture that will be the same as that region on the referent picture. It has the following format:

[FULL_SCREEN] "point1_x x_start" "point1_y y_start" "point2_x x_end" "point2_y y_end"

For the exact coordinates that should be defined here, the tool called Reference Creator can be used.

 

Limitation of this approach Go to top

One limitation is that the special stream is needed for a particular type of video presence testing, e.g. if you want to test if there is a video present, you can’t always test this on a live stream, because that stream is unpredictable. It is always better to use the custom static referent stream, but the creation of that type of stream is proven to be a time consuming task.

 

Test implementation in Python Go to top

For your reference, a full example is available in the source code below:

## @package Video presence
# The test is performed by checking if video signal is present on HDMI interface after zapping.
# If the video is presented, the test checks if the black screen image is removed from the video output.
# If the black screen image is removed, the test checks if the images change after zapping or the screen is static.
# 
# This functionality that checks if any signal is present on selected input of grabber device,
# (if device under test is sending valid signal to the desired output) can be done for any 
# available video input on grabber device (HDMI, CVBS, COMPONENT, S-VIDEO...).
#
# test_name = Video presence
# ID = Path of test case in Intent+
# copyright = 2014 RT-RK. All rights reserved.

## This module provides various time-related functions
import time

## This module contains common definitions used through various tests for Black Box testing.
import TEST_CREATION_API

## Zapping time in digital systems isn't a constant category,
# but there are always some values defined as max zapping duration,
# time in which the zapping will be completed. Here we define max zapping time in seconds.
MAX_ZAP_TIME_DURATION = 6

## Number of snapshots to grab
SNAPSHOTS_NUMBER = 10

## Test steps execution
def runTest():
    ## Use Try Except block to catch errors detected during execution
    try:
        ## Set initial result of test execution to FAIL
        test_result = "FAIL"

        ## Initialize grabber device
        # (enable communication between PC and grabber device through LAN interface)
        TEST_CREATION_API.initialize_grabber()

        ## Start grabbing video on video interface (HDMI1)
        # Preview is turned on by default
        # (to turn off the preview set second parameter of function to False)
        TEST_CREATION_API.grabber_start_video_source(TEST_CREATION_API.VideoInterface.HDMI1)

        ## Send RC command to DUT to bring DUT to initial state
        # ([INIT] macro is defined in RemoteController.ini file)
        TEST_CREATION_API.send_ir_rc_command("[INIT]")
         
        ## Tune to scanned channel
        TEST_CREATION_API.send_ir_rc_command("[CH_1]")
        time.sleep(MAX_ZAP_TIME_DURATION)

        ## Check if video signal is present on HDMI interface
        if (TEST_CREATION_API.is_signal_present_on_video_source()):
            ## Check if captured picture is different from referent one.
            # Macro [FULL_SCREEN] is defined in RT-AV101.ini file.
            # Macro [FULL_SCREEN] is used to monitor precise region in the picture
            # that will be different as that region on referent picture.
            if (TEST_CREATION_API.wait_for_picture("black_screen.bmp", "[FULL_SCREEN]", MAX_ZAP_TIME_DURATION, TEST_CREATION_API.DEFAULT_HDMI_VIDEO_THRESHOLD, TEST_CREATION_API.WaitForPicture.DIFFERENT)):
                ## Grab multiple pictures (SNAPSHOTS_NUMBER)
                # The file will be recorded in BMP format, so the file name extension is excluded here.
                TEST_CREATION_API.grab_picture("zapping", SNAPSHOTS_NUMBER)

                ## Compare multiple pictures with one referent picture
                # or with first of test pictures if referent is not set.
                # To use referent picture add name of picture as fourth parameter.
                # To use custom threshold for matching
                # referent and test picture set fifth parameter as integer from 0 to 100.
                # If region is set only region of interest is compared.
                # If region is not set whole pictures are compared by default.
                # Macro [FULL_SCREEN] is defined in PictureAlgorithm.ini file.
                # The file name here presents only a prefix,
                # because the picture names should be in format:
                # filename_0_0.bmp...filename_0_N.bmp
                if (TEST_CREATION_API.compare_multiple_pictures("zapping", "[FULL_SCREEN]", SNAPSHOTS_NUMBER)):
                    ## Set test result variable to PASS if pictures are the same
                    test_result = "PASS"
                else:
                    ## Write message to log file if comparing of pictures returns False and continue execution
                    TEST_CREATION_API.write_log_to_file("Pictures after zapping are static.")
            else:
                ## Write message to log file if the black screen is displayed after timeout and continue execution
                TEST_CREATION_API.write_log_to_file("Zapping went wrong.")
        else:
            ## Write message to log file if video signal is not present and continue execution
            TEST_CREATION_API.write_log_to_file("Video signal is not present on HDMI interface")

    ## If exception is detected,
    # test result variable is set to INCONCLUSIVE and log of error is written to log file
    except Exception as error:
        ## Set test result variable to INCONCLUSIVE if exception is caught
        test_result = "INCONCLUSIVE"

        ## Write exception message to log file
        TEST_CREATION_API.write_log_to_file(error)

    ## Update test result with current state of test_result variable
    TEST_CREATION_API.update_test_result(test_result)

    ## Return DUT to initial state
    TEST_CREATION_API.send_ir_rc_command("[INIT]")

    ## Stop grabbing video on HDMI1 interface
    TEST_CREATION_API.grabber_stop_video_source()

    ## Deinitialize grabber device
    TEST_CREATION_API.deinitialize_grabber()