H264和opencv for python的问题

时间:2018-05-06 21:55:15

标签: python opencv 3dr

您好我正在尝试使用python中的telnet,h264和opencv通过3DR solo从gopro流式传输。

首先我在一个终端运行:     telnet 10.1.1.1 5502

运行sololink.sdp的

包含:

c=IN IP4 10.1.1.1
m=video 5600 RTP/AVP 96
a=rtpmap:96 H264/90000
t=0 0

然后当我在其他终端运行时:     python colortracking.py 我收到了这个错误:

[h264 @ 0x2206440] negative number of zero coeffs at 35 30
[h264 @ 0x2206440] error while decoding MB 35 30
[h264 @ 0x2231920] out of range intra chroma pred mode at 24 30
[h264 @ 0x2231920] error while decoding MB 24 30
[h264 @ 0x2206440] out of range intra chroma pred mode at 29 32
[h264 @ 0x2206440] error while decoding MB 29 32

这是我的代码:

import cv2
import numpy as np

def getthresholdedimg1(hsv):#Amarillo
    threshImg = cv2.inRange(hsv,(25,100,20),(30,255,255))
    return threshImg

def getthresholdedimg2(hsv):#Rosa
    threshImg = cv2.inRange(hsv,(145,100,20),(155,255,255))
    return threshImg    

def getthresholdedimg3(hsv):#Rojo
    threshImg = cv2.inRange(hsv,(170,100,20),(180,255,255))
    return threshImg  

def getthresholdedimg4(hsv):#Verde
    threshImg = cv2.inRange(hsv,(50,100,20),(70,255,255))
    return threshImg 

def getthresholdedimg5(hsv):#Naranja
    threshImg = cv2.inRange(hsv,(5,100,20),(15,255,255))
    return threshImg    



#c = cv2.VideoCapture(0)
c = cv2.VideoCapture("./sololink.sdp")
#c = cv2.VideoCapture(10.1.1.1)
width,height = c.get(3),c.get(4)




#Declarar ventanas
cv2.namedWindow('Output', cv2.WINDOW_NORMAL)


print'''..::Presione La Letra ESC Para Salir::..
 >Presiona 1 para seguir el  Color Amarillo
 >Presiona 2 para seguir el  Color Rosa
 >Presiona 3 para seguir el  Color Rojo
 >Presiona 4 para seguir el  Color Verde
 >Presiona 5 para seguir el  Color Naranja\n\n'''

color = input(" Presione el color que desea seguir: \n")
while(1):



    k =cv2.waitKey(10)
    if k== 27: #ESC for exit
    #if cv2.waitKey(10) & 0xFF == ord('q'):
        break
    _,f = c.read()
    f = cv2.flip(f,1)
    blur = cv2.medianBlur(f,5)
    hsv = cv2.cvtColor(f,cv2.COLOR_BGR2HSV)

    #Leyendo color de input
    if color==1:
        thrImg = getthresholdedimg1(hsv)
    elif color ==2:
        thrImg = getthresholdedimg2(hsv)
    elif color ==3:
        thrImg = getthresholdedimg3(hsv)
    elif color ==4:
        thrImg = getthresholdedimg4(hsv)
    elif color ==5:
        thrImg = getthresholdedimg5(hsv)

    if k== 49: #1
        print "Siguiendo Color Amarillo"
        color=1  
    if k==50: #2
        print "Siguiendo Color Rosa"
        color=2
    if k==51:
        print "Siguiendo Color Rojo"
        color=3
    if k==52:
        print "Siguiendo Color Verde"
        color=4
    if k==53:
        print "Siguiendo Color Naranja"
        color=5

    erode = cv2.erode(thrImg,None,iterations = 3)
    dilate = cv2.dilate(erode,None,iterations = 10)

    image,contours,hierarchy = cv2.findContours(dilate,cv2.RETR_LIST,cv2.CHAIN_APPROX_SIMPLE)

    for cnt in contours:
        x,y,w,h = cv2.boundingRect(cnt)
        cx,cy = x+w/2, y+h/2
        cv2.rectangle(f,(x,y),(x+w,y+h),[0,0,255],2)

    cv2.imshow('Output',f)




cv2.destroyAllWindows()
c.release()

你知道我做错了吗?

0 个答案:

没有答案