Hello I am trying to stream from a gopro by 3DR solo using telnet ,h264 and opencv in python.
First I run in one terminal: telnet 10.1.1.1 5502
that runs the sololink.sdp which contains:
c=IN IP4 10.1.1.1
m=video 5600 RTP/AVP 96
a=rtpmap:96 H264/90000
t=0 0
then when I run in other terminal: python colortracking.py I got this errors:
[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
here is my code:
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()
Do you know what I'm doing wrong?