コード例 #1
0
ファイル: test.py プロジェクト: k4ppa/SkyOnlineDemo
def _videoMotionTest():
    """
    Checks if there is motion present in the video
    SDO only allows threshold of 1% minumum, so we run it repeatedly for 5s and if it fails
    we check the actual motion against a threshold of 0.1%
    Requires:
    - a Screen Definition file "DetectMotion.stscreen" 
    Returns:
    - result: boolean True or False
    - comment: a comment giving more details of the test result
    - image: a screenshot of the test
    """

    result = False
    repeat = 6
    count = 0
    SDO = StormTest.ScreenDefinition()
    try:
        SDO.Load('DetectMotion.stscreen')
        #we check every 5 seconds for motion > 0.1%
        while (result == False) and (count <= repeat):
            retSDO = StormTest.WaitScreenDefMatch(SDO)[0][1]
            result = retSDO.VerifyStatus
            actualMotion = retSDO.Regions[0].ActualMotion
            StormTest.WriteDebugLine('Actual motion detected is ' +
                                     str(actualMotion))
            if actualMotion > 0.1:
                result = True
            count = count + 1

            StormTest.WriteDebugLine('Result of Motion Detection is ' +
                                     str(result))
            image = retSDO.Image
            image.Save('VideoMotion_%d_%t.jpeg')
            motionThreshold = 0.1
            comment = 'Motion Level = %0.3f, Motion Threshold = %0.3f' % (
                actualMotion, motionThreshold)
        SDO.Close()
        return [result, comment, image]
    except:
        print 'Could not load DetectMotion.stscreen - exiting test'
        SDO.Close()
        return [False, 'Could not load DetectMotion.stscreen - exiting test']
コード例 #2
0
ファイル: test.py プロジェクト: k4ppa/SkyOnlineDemo
def _videoPresentTest():
    """
    Checks if video is present, by comparing screen colour against a black colour
    Requires:
    - a Screen Definition file called "DetectVideoPresence.stscreen"
    Returns:
    - result: boolean True or False
    - comment: a comment giving more details of the test result
    - image: a screenshot of the test
    """

    result = False
    repeat = 10
    count = 0
    SDO = StormTest.ScreenDefinition()
    try:
        SDO.Load('DetectVideoPresence.stscreen')
        while (result == False) and (count <= repeat):
            #note this SDO returns True when a match does *not* occur
            retSDO = StormTest.WaitScreenDefMatch(SDO)[0][1]
            result = retSDO.VerifyStatus
            StormTest.WriteDebugLine(
                'Result of matching screen with black was ' + str(not result))
            count = count + 1
            if (result == False) and (count <= repeat):
                StormTest.WaitSec(4)
                StormTest.WriteDebugLine('Retry, count = ' + str(count))
        image = retSDO.Image
        image.Save('VideoPresent_%d_%t.jpeg')
        comment = 'Result of matching screen with black was ' + str(not result)
        SDO.Close()
        return [result, comment, image]
    except:
        print 'Could not load DetectVideoPresence.stscreen - exiting test'
        SDO.Close()
        return [
            False,
            'Could not load DetectVideoPresence.stscreen - exiting test', image
        ]
コード例 #3
0
ファイル: test.py プロジェクト: k4ppa/SkyOnlineDemo
def _audioPresentTest():
    #print StormTest.GetAudioLevel(1)
    SDO = StormTest.ScreenDefinition()
    try:
        SDO.Load('AudioDetect.stscreen')
        retSDO = StormTest.WaitScreenDefMatch(SDO)[0][1]
        actualAudio = retSDO.Regions[0].ActualAudio
        audioThreshold = retSDO.Regions[0].AudioThreshold
        isPresent = StormTest.WaitAudioPresence(-110, 60)[0][1]
        StormTest.WriteDebugLine('Result of Audio Detection is ' +
                                 str(isPresent) + '. Actual audio level = ' +
                                 str(actualAudio))
        comment = 'Audio Level = %0.3f, Audio Threshold = %0.3f' % (
            actualAudio, audioThreshold)
        print comment
        SDO.Close()
    except:
        print 'Could not load AudioDetect.stscreen - exiting test'
        SDO.Close()

    if isPresent:
        return isPresent, 'Audio is present' + comment
    else:
        return isPresent, 'Audio not present' + comment