视频智能中发生多值错误

我已经使用视频智能来分析视频文件。

到目前为止,我一直在使用以下代码分析视频。

但是,突然发生以下错误。

错误的详细信息如下。

错误:

Traceback (most recent call last):
File "imagedetect10.py",line 26,in <module>
FNURL,features=features,video_context=context)
TypeError: annotate_video() got multiple values for argument 'features'

其中列出了这些代码,名称为imagedetect10.py。

imagedetect10.py:

    """ Detects labels given a GCS path. """
    # coding: utf-8
    import csv
    # from google.cloud import videointelligence_v1beta2
    from google.cloud import videointelligence
    # ask file name
    FNA = input("Please Enter File name:")

    FNURL = 'gs://fcc_contents_st01/' + FNA + '.mp4'
    FNF = FNA + '.csv'
    FNFCB = FNA + 'cb' + '.csv'
    FNFBR = FNA + 'br' + '.csv'
    FNFB = FNA + 'b' + '.csv'

    # main
    video_client = videointelligence.VideoIntelligenceServiceclient()
    features = [videointelligence.enums.Feature.LABEL_DETECTION]

    mode = videointelligence.enums.LabelDetectionmode.SHOT_AND_FRAME_MODE
    config = videointelligence.types.LabelDetectionconfig(
        label_detection_mode=mode)
    context = videointelligence.types.VideoContext(
        label_detection_config=config)

    operation = video_client.annotate_video(
        FNURL,video_context=context)
    print('\nProcessing video for label annotations:')

    result = operation.result(timeout=2000)
    print('\nFinished processing.')

    # Process video/segment level label annotations
    segment_labels = result.annotation_results[0].segment_label_annotations
    for i,segment_label in enumerate(segment_labels):
        print('Video label description: {}'.format(
            segment_label.entity.description))
        for category_entity in segment_label.category_entities:
            print('\tLabel category description: {}'.format(
                category_entity.description))

        for i,segment in enumerate(segment_label.segments):
            start_time = (segment.segment.start_time_offset.seconds +
                          segment.segment.start_time_offset.nanos / 1e9)
            end_time = (segment.segment.end_time_offset.seconds +
                        segment.segment.end_time_offset.nanos / 1e9)
            positions = '{}s to {}s'.format(start_time,end_time)
            confidence = segment.confidence
            print('\tSegment {}: {}'.format(i,positions))
        print('\n')

    # Process shot level label annotations
    shot_labels = result.annotation_results[0].shot_label_annotations
    for i,shot_label in enumerate(shot_labels):
        print('Shot label description: {}'.format(
            shot_label.entity.description))
        for category_entity in shot_label.category_entities:
            print('\tLabel category description: {}'.format(
                category_entity.description))

        for i,shot in enumerate(shot_label.segments):
            start_time = (shot.segment.start_time_offset.seconds)
            end_time = (shot.segment.end_time_offset.seconds)
            positions = '{}s to {}s'.format(start_time,end_time)
            confidence = shot.confidence
            print('\tSegment {}: {}'.format(i,positions))
            print('\tConfidence: {}'.format(confidence))
            with open(FNF,'a') as f:
                writer = csv.writer(f,lineterminator='\n')
                writer.writerow(
                    [i,start_time,end_time,shot_label.entity.description])
            if shot_label.entity.description == 'brand':
                with open(FNFBR,'a') as f:
                    writer = csv.writer(f,lineterminator='\n')
                    writer.writerow(
                        [i,shot_label.entity.description])
            if shot_label.entity.description == 'symmetry':
                with open(FNFCB,shot_label.entity.description])

            if shot_label.entity.description == 'black':
                with open(FNFB,shot_label.entity.description])

        print('\n')

你能告诉我怎么了吗?

非常感谢您!

xzj700106 回答:视频智能中发生多值错误

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3052083.html

大家都在问