Python Onvif 控件

问题描述

我用python做了一切来操作ptz

我不确定焦点的输入/输出。 onvif首页,好像是焦点移动。

我不知道要获取和编辑什么值,所以我会上传它。

而且即使在调整光圈(光圈)值时,降低该值也可以,但是如果您做了+,则该值变化不大

在这种情况下,我认为

ptz = mycam.create_imaging_service()

如果您通过 ptz.Getoptions() 查看选项,则最大光圈值为 0,最小值为 -22。

media = mycam.create_media_service()

media_profile = media.GetVideoSources()[0]

这里,相机的图像设置是通过 GetVideoSources 加载的。从这个值,在 Imaging.Exposure

有当前光圈值的Iris,最大光圈值的MaxIris,最小光圈值的MinIris。

如果当前光圈值为-5,则MinIris取-22,但MaxIris取当前光圈值-5。

似乎即使每次加载时都带上更改后的值也不会更改,但是如果您知道如何修复它,请。

@api_view(['POST'])
def getMovePTZ(request):
    logger.debug("getMovePTZ start : %s",request.data)
    ptz_type = request.data.get('data')['ptz_type']
    ptz_direction = request.data.get('data')['ptz_direction']
    ptz_active = request.data.get('data')['ptz_active']

    Min = {}
    Max = {}

    if ptz_type == 'iris':
        # Create img service object
        ptz = mycam.create_imaging_service()
        imgrequest = ptz.create_type('GetImagingSettings')
        # Get target profile
        media_profile = media.GetVideoSources()[0]
        imgrequest.VideoSourcetoken = media_profile.token
        img_configuration_options = ptz.Getoptions(imgrequest)

        moverequest = ptz.create_type('SetImagingSettings')
        moverequest.VideoSourcetoken = media_profile.token
        if moverequest.ImagingSettings is None:
            moverequest.ImagingSettings = ptz.GetImagingSettings({'VideoSourcetoken': media_profile.token})
            Min['iris'] = img_configuration_options.Exposure.Iris.Min
            Max['iris'] = img_configuration_options.Exposure.Iris.Max
    else:
        # Create ptz service object
        ptz = mycam.create_ptz_service()
        ptzrequest = ptz.create_type('GetConfigurationoptions')
        # Get target profile
        media_profile = media.GetProfiles()[0]
        ptzrequest.ConfigurationToken = media_profile.PTZConfiguration.token
        ptz_configuration_options = ptz.GetConfigurationoptions(ptzrequest)
        moverequest = ptz.create_type('ContinuousMove')
        moverequest.Profiletoken = media_profile.token
        if moverequest.VeLocity is None:
            moverequest.VeLocity = ptz.GetStatus({'Profiletoken': media_profile.token}).Position
            moverequest.VeLocity.PanTilt.space = ptz_configuration_options.Spaces.ContinuousPanTiltVeLocitySpace[0].URI
            moverequest.VeLocity.Zoom.space = ptz_configuration_options.Spaces.ContinuousZoomVeLocitySpace[0].URI
    direction = {
        'panning': move_panning,'upleft': move_upleft,'up': move_up,'upright': move_upright,'left': move_left,'right': move_right,'downleft': move_downleft,'down': move_down,'downright': move_downright,'wide': zoom_wide,'tele': zoom_tele,'in': iris_in,'out': iris_out,}
    func = direction[ptz_direction]
    if ptz_type == 'iris':
        func(ptz,moverequest,ptz_active)
    else:
        func(ptz,Min,Max)
    return Response(None)


def ptz_move(ptz,request,active):
    if active:
        ptz.ContinuousMove(request)
    else:
        ptz.Stop({'Profiletoken': request.Profiletoken})


def move_panning(ptz,active):
    request.VeLocity.PanTilt.x = XMOVE
    request.VeLocity.PanTilt.y = 0
    request.VeLocity.Zoom.x = 0
    ptz_move(ptz,active)


def move_up(ptz,active):
    request.VeLocity.PanTilt.y = YMOVE
    request.VeLocity.PanTilt.x = 0
    request.VeLocity.Zoom.x = 0
    ptz_move(ptz,active)


def move_down(ptz,active):
    request.VeLocity.PanTilt.y = -YMOVE
    request.VeLocity.PanTilt.x = 0
    request.VeLocity.Zoom.x = 0
    ptz_move(ptz,active)


def move_right(ptz,active)


def move_left(ptz,active):
    request.VeLocity.PanTilt.x = -XMOVE
    request.VeLocity.PanTilt.y = 0
    request.VeLocity.Zoom.x = 0
    ptz_move(ptz,active)


def move_upleft(ptz,active):
    request.VeLocity.PanTilt.x = -XMOVE
    request.VeLocity.PanTilt.y = YMOVE
    request.VeLocity.Zoom.x = 0
    ptz_move(ptz,active)


def move_upright(ptz,active):
    request.VeLocity.PanTilt.x = XMOVE
    request.VeLocity.PanTilt.y = YMOVE
    request.VeLocity.Zoom.x = 0
    ptz_move(ptz,active)


def move_downleft(ptz,active):
    request.VeLocity.PanTilt.x = -XMOVE
    request.VeLocity.PanTilt.y = -YMOVE
    request.VeLocity.Zoom.x = 0
    ptz_move(ptz,active)


def move_downright(ptz,active):
    request.VeLocity.PanTilt.x = XMOVE
    request.VeLocity.PanTilt.y = -YMOVE
    request.VeLocity.Zoom.x = 0
    ptz_move(ptz,active)


def zoom_wide(ptz,active):
    request.VeLocity.Zoom.x = -ZMOVE
    request.VeLocity.PanTilt.x = 0
    request.VeLocity.PanTilt.y = 0
    ptz_move(ptz,active)


def zoom_tele(ptz,active):
    request.VeLocity.Zoom.x = ZMOVE
    request.VeLocity.PanTilt.x = 0
    request.VeLocity.PanTilt.y = 0
    ptz_move(ptz,active)


def iris_in(ptz,Max):
    request.ImagingSettings.Exposure.Iris -= 1
    if request.ImagingSettings.Exposure.Iris < Min['iris']:
        request.ImagingSettings.Exposure.Iris = Min['iris']
    ptz.SetImagingSettings(request)


def iris_out(ptz,Max):
    request.ImagingSettings.Exposure.Iris += 1
    if request.ImagingSettings.Exposure.Iris > Max['iris']:
        request.ImagingSettings.Exposure.Iris = Max['iris']
    ptz.SetImagingSettings(request)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...