Python “如何修复”;TypeError:int()参数必须是字符串、类似字节的对象或数字,而不是';非类型'&引用;?

Python “如何修复”;TypeError:int()参数必须是字符串、类似字节的对象或数字,而不是';非类型'&引用;?,python,opencv,tensorflow,gstreamer,nvidia-jetson,Python,Opencv,Tensorflow,Gstreamer,Nvidia Jetson,我的目标是将目标检测视频从Raspberry Pi摄像头传输到UDP。我在Nvidia Jetson Nano(Ubuntu18.04)上这么做。我正在使用gstreamer来捕获视频。我必须用h264编码视频。相机的像素格式为“RG10”。我尝试了不同的管道来捕获视频,但没有任何改变。我认为,问题在于捕捉视频。我不明白。我是新手。所以我需要帮助 以下是代码: import os import numpy as np import tensorflow as tf import sys sy

我的目标是将目标检测视频从Raspberry Pi摄像头传输到UDP。我在Nvidia Jetson Nano(Ubuntu18.04)上这么做。我正在使用gstreamer来捕获视频。我必须用h264编码视频。相机的像素格式为“RG10”。我尝试了不同的管道来捕获视频,但没有任何改变。我认为,问题在于捕捉视频。我不明白。我是新手。所以我需要帮助

以下是代码:


import os
import numpy as np
import tensorflow as tf
import sys

sys.path.append('/usr/local/lib/python3.6/dist-packages')
import cv2 as cv2

from utils import label_map_util
from utils import visualization_utils as vis_util

MODEL_NAME = 'inference_graph'
CWD_PATH = os.getcwd()
PATH_TO_CKPT = os.path.join(CWD_PATH,MODEL_NAME,'frozen_inference_graph.pb')
PATH_TO_LABELS = os.path.join(CWD_PATH,'training','labelmap.pbtxt')
NUM_CLASSES = 1

label_map = label_map_util.load_labelmap(PATH_TO_LABELS)
categories = label_map_util.convert_label_map_to_categories(label_map, max_num_classes=NUM_CLASSES, use_display_name=True)
category_index = label_map_util.create_category_index(categories)

detection_graph = tf.Graph()
with detection_graph.as_default():
    od_graph_def = tf.GraphDef()
    with tf.gfile.GFile(PATH_TO_CKPT, 'rb') as fid:
        serialized_graph = fid.read()
        od_graph_def.ParseFromString(serialized_graph)
        tf.import_graph_def(od_graph_def, name='')
    sess = tf.Session(graph=detection_graph)

image_tensor = detection_graph.get_tensor_by_name('image_tensor:0')

detection_boxes = detection_graph.get_tensor_by_name('detection_boxes:0')
detection_scores = detection_graph.get_tensor_by_name('detection_scores:0')
detection_classes = detection_graph.get_tensor_by_name('detection_classes:0')
num_detections = detection_graph.get_tensor_by_name('num_detections:0')

writer = cv2.VideoWriter(" appsrc name=appsrc_element block=true ! video/x-raw,format=RGB,width=320,height=240,framerate=30/1 ! identity check-imperfect-timestamp=true ! videoconvert ! x264enc ! video/x-h264,profile=\"high-4:4:4\ ! rtph264pay  ! udpsink host= 192.168.1.49 port=5000 ",cv2.CAP_GSTREAMER,0, 20, (320,240), True) # Write frames here after processing


video = cv2.VideoCapture('nvarguscamerasrc ! image/jpg,width=1280,height=720,type=video,framerate=30/1 ! videoscale ! videoconvert ! x264enc tune=zerolatency ! rtph264pay ! appsink ', cv2.CAP_GSTREAMER)
ret = video.set(3,1280)
ret = video.set(4,720)

while(True):


    ret, frame = video.read()   
    frame_expanded = np.expand_dims(frame, axis=0)


    (boxes, scores, classes, num) = sess.run(
        [detection_boxes, detection_scores, detection_classes, num_detections],
        feed_dict={image_tensor: frame_expanded})

    vis_util.visualize_boxes_and_labels_on_image_array(
        frame,
        np.squeeze(boxes),
        np.squeeze(classes).astype(np.int32),
        np.squeeze(scores),
        category_index,
        use_normalized_coordinates=True,
        line_thickness=8,
        min_score_thresh=0.85)

    w_size = cv2.getWindowImageRect('frame')

    print(w_size)
    cv2.rectangle(frame,(int(int(w_size[2])*0.25) ,int(int(w_size[3])*0.10)),(int(int(w_size[2])*0.75),int(int(w_size[3])*0.90)),(0,255,0),3)

    writer.write(frame) 


    if cv2.waitKey(1) == ord('q'):
        break

video.release()
writer.release()
cv2.destroyAllWindows()
这是输出错误:

  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/home/berfu/.virtualenvs/deep_learning/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/home/berfu/.virtualenvs/deep_learning/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:528: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
/home/berfu/.virtualenvs/deep_learning/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:529: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/home/berfu/.virtualenvs/deep_learning/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:530: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
/home/berfu/.virtualenvs/deep_learning/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:535: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
2019-09-07 02:26:33.800624: W tensorflow/core/platform/profile_utils/cpu_utils.cc:98] Failed to find bogomips in /proc/cpuinfo; cannot determine CPU frequency
2019-09-07 02:26:33.804717: I tensorflow/compiler/xla/service/service.cc:161] XLA service 0x2816fdf0 executing computations on platform Host. Devices:
2019-09-07 02:26:33.805320: I tensorflow/compiler/xla/service/service.cc:168]   StreamExecutor device (0): <undefined>, <undefined>
2019-09-07 02:26:33.895575: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:965] ARM64 does not support NUMA - returning NUMA node zero
2019-09-07 02:26:33.895923: I tensorflow/compiler/xla/service/service.cc:161] XLA service 0x24aca990 executing computations on platform CUDA. Devices:
2019-09-07 02:26:33.895984: I tensorflow/compiler/xla/service/service.cc:168]   StreamExecutor device (0): NVIDIA Tegra X1, Compute Capability 5.3
2019-09-07 02:26:33.896452: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1433] Found device 0 with properties: 
name: NVIDIA Tegra X1 major: 5 minor: 3 memoryClockRate(GHz): 0.9216
pciBusID: 0000:00:00.0
totalMemory: 3.86GiB freeMemory: 272.39MiB
2019-09-07 02:26:33.896515: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512] Adding visible gpu devices: 0
2019-09-07 02:26:35.073590: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-09-07 02:26:35.073769: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990]      0 
2019-09-07 02:26:35.073809: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1003] 0:   N 
2019-09-07 02:26:35.074121: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 42 MB memory) -> physical GPU (device: 0, name: NVIDIA Tegra X1, pci bus id: 0000:00:00.0, compute capability: 5.3)
GST_ARGUS: Creating output stream
CONSUMER: Waiting until producer is connected...
GST_ARGUS: Available Sensor modes :
GST_ARGUS: 3280 x 2464 FR = 21.000000 fps Duration = 47619048 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 3280 x 1848 FR = 28.000001 fps Duration = 35714284 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1920 x 1080 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1280 x 720 FR = 59.999999 fps Duration = 16666667 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1280 x 720 FR = 120.000005 fps Duration = 8333333 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: Running with following settings:
   Camera index = 0 
   Camera mode  = 2 
   Output Stream W = 1920 H = 1080 
   seconds to Run    = 0 
   Frame Rate = 29.999999 
GST_ARGUS: PowerService: requested_clock_Hz=13608000
GST_ARGUS: Setup Complete, Starting captures for 0 seconds
GST_ARGUS: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
GST_ARGUS: Cleaning up
GST_ARGUS: 
PowerServiceHwVic::cleanupResources
CONSUMER: Done Success
GST_ARGUS: Done Success
<class 'NoneType'>
Traceback (most recent call last):
  File "webcam.py", line 68, in <module>
    feed_dict={image_tensor: frame_expanded})
  File "/home/berfu/.virtualenvs/deep_learning/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 929, in run
    run_metadata_ptr)
  File "/home/berfu/.virtualenvs/deep_learning/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1121, in _run
    np_val = np.asarray(subfeed_val, dtype=subfeed_dtype)
  File "/home/berfu/.virtualenvs/deep_learning/lib/python3.6/site-packages/numpy/core/_asarray.py", line 85, in asarray
    return array(a, dtype, copy=False, order=order)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
\u np\u qint8=np.dtype([(“qint8”,np.int8,1)])
/home/berfu/.virtualenvs/deep_learning/lib/python3.6/site packages/tensorflow/python/framework/dtypes.py:527:FutureWarning:Passing(type,1)或'1type'作为type的同义词是不推荐的;在numpy的未来版本中,它将被理解为(type,(1,)/“(1,)type”。
_np_quint8=np.dtype([(“quint8”,np.uint8,1)])
/home/berfu/.virtualenvs/deep_learning/lib/python3.6/site packages/tensorflow/python/framework/dtypes.py:528:FutureWarning:Passing(type,1)或'1type'作为type的同义词是不推荐的;在numpy的未来版本中,它将被理解为(type,(1,)/“(1,)type”。
_np_qint16=np.dtype([(“qint16”,np.int16,1)])
/home/berfu/.virtualenvs/deep_learning/lib/python3.6/site packages/tensorflow/python/framework/dtypes.py:529:FutureWarning:Passing(type,1)或'1type'作为type的同义词是不推荐的;在numpy的未来版本中,它将被理解为(type,(1,)/“(1,)type”。
_np_quint16=np.dtype([(“quint16”,np.uint16,1)])
/home/berfu/.virtualenvs/deep_learning/lib/python3.6/site packages/tensorflow/python/framework/dtypes.py:530:FutureWarning:Passing(type,1)或'1type'作为type的同义词是不推荐的;在numpy的未来版本中,它将被理解为(type,(1,)/“(1,)type”。
_np_qint32=np.dtype([(“qint32”,np.int32,1)])
/home/berfu/.virtualenvs/deep_learning/lib/python3.6/site packages/tensorflow/python/framework/dtypes.py:535:FutureWarning:Passing(type,1)或'1type'作为type的同义词是不推荐的;在numpy的未来版本中,它将被理解为(type,(1,)/“(1,)type”。
np_resource=np.dtype([(“resource”,np.ubyte,1)])
2019-09-07 02:26:33.800624:W tensorflow/core/platform/profile_utils/cpu_utils.cc:98]在/proc/cpuinfo中找不到bogomips;无法确定CPU频率
2019-0907 0226: 33.804717:I TysFrace/编译器/ XLA/Service / Service .CC:161)XLA服务0x28 16FDF0在平台主机上执行计算。设备:
2019-09-07 02:26:33.805320:I tensorflow/compiler/xla/service/service.cc:168]流执行器设备(0):,
2019-09-07 02:26:33.895575:I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:965]ARM64不支持NUMA-返回NUMA节点零
2019-0907 0226: 33.895923:I TysFult/Cyp/XLA/Service / Service .CC:161)XLA服务0x24ACA990在CUDA平台上执行计算。设备:
2019-09-07 02:26:33.895984:I tensorflow/compiler/xla/service/service.cc:168]StreamExecutor设备(0):NVIDIA Tegra X1,计算能力5.3
2019-09-07 02:26:33.896452:I tensorflow/core/common_runtime/gpu/gpu_device.cc:1433]找到了具有以下属性的设备0:
名称:NVIDIA Tegra X1大调:5小调:3记忆时钟频率(GHz):0.9216
pciBusID:0000:00:00.0
totalMemory:3.86GiB自由内存:272.39MiB
2019-09-07 02:26:33.896515:I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512]添加可见gpu设备:0
2019-09-07 02:26:35.073590:I tensorflow/core/common_runtime/gpu/gpu_device.cc:984]设备互连拖缆执行器与强度1边缘矩阵:
2019-09-07 02:26:35.073769:I tensorflow/core/common_runtime/gpu/gpu_device.cc:990]0
2019-09-07 02:26:35.073809:I tensorflow/core/common_runtime/gpu/gpu_device.cc:1003]0:N
2019-09-07 02:26:35.074121:I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115]创建tensorflow设备(/job:localhost/replica:0/task:0/device:gpu:0,42 MB内存)->物理gpu(设备:0,名称:NVIDIA Tegra X1,pci总线id:0000:00:00.0,计算能力:5.3)
GST_ARGUS:创建输出流
消费者:正在等待生产者连接。。。
GST_ARGUS:可用传感器模式:
GST_ARGUS:3280 x 2464 FR=21.000000 fps时长=47619048;模拟增益范围最小为1.000000,最大为10.625000;暴露范围最小13000,最大683709000;
GST_ARGUS:3280 x 1848 FR=28.000001 fps时长=35714284;模拟增益范围最小为1.000000,最大为10.625000;暴露范围最小13000,最大683709000;
GST_ARGUS:1920 x 1080 FR=29.9999999 fps时长=3333 4;模拟增益范围最小为1.000000,最大为10.625000;暴露范围最小13000,最大683709000;
GST_ARGUS:1280 x 720 FR=59.999999 fps时长=16666667;模拟增益范围最小为1.000000,最大为10.625000;暴露范围最小13000,最大683709000;
GST_ARGUS:1280 x 720 FR=120.000005 fps时长=8333333;模拟增益范围最小为1.000000,最大为10.625000;暴露范围最小13000,最大683709000;
GST_ARGUS:使用以下设置运行:
摄影机索引=0
相机模式=2
输出流W=1920 H=1080
运行秒数=0
帧速率=29.999999
GST\u ARGUS:PowerService:requested\u clock\u Hz=13608000
GST_ARGUS:安装完成,开始捕获0秒
GST_ARGUS:开始重复捕获请求。
消费者:生产者已连接;持续的。
GST_ARGUS:清理
GST_ARGUS:
PowerServiceHwVic::cleanupResources
消费者:成功了吗
GST_ARGUS:取得成功
回溯(最近一次呼叫最后一次):
文件“webcam.py”,第68行,在
feed_dict={image_tensor:frame_expanded})
文件“/home/berfu/.virtualenvs/deep_learning/lib/python3.6/site packages/tensorflow/python/client/session.py”,第929行,正在运行
运行_元数据_ptr)
文件“/home/berfu/.virtualenvs/deep\u learning/lib/python3.6/site packages/tensorflow/python/client/session.py”,第1121行,在运行中
np\u val=np.asarray(subfeed\u val,dtype=subfeed\u dtype)
文件“/home/berfu/.virtualenvs/deep_learning/lib/python3.6/site-packages/n