2017-10-09 27 views
-1

我是新的python。請幫我解決下面的問題。 「無效參數」的含義是什麼?無法啓動捕獲:無效的參數

下面的代碼都很好,但是當我添加代碼時,通過dataplicity發佈實時流。將出現錯誤「無法啓動捕獲:無效參數i:錯誤抓取幀」。在發佈直播流的錯誤之後,下面的這些功能將在移動檢測時進行。

我在DEF is_person(圖像)的頂部添加代碼導致錯誤:

os.system('sudo ./mjpg_streamer -i "./input_uvc.so -f 10 -r 640x320 -n -y" -o "./output_http.so -w ./www -p 80"') 

def is_person(image): 

    det = Detector(image) 
    faces = len(det.face()) 
    print ("FACE: "), det.drawColors[det.drawn-1 % len(det.drawColors)], faces 
    uppers = len(det.upper_body()) 
    print ("UPPR: "), det.drawColors[det.drawn-1 % len(det.drawColors)], uppers 
    fulls = len(det.full_body()) 
    print ("FULL: "), det.drawColors[det.drawn-1 % len(det.drawColors)], fulls 
    peds = len(det.pedestrian()) 
    print ("PEDS: "), det.drawColors[det.drawn-1 % len(det.drawColors)], peds 
    det.draw() 
    det.overlay() 

    return faces + uppers + fulls + peds 
    # return len(det.face()) or len(det.full_body()) or len(det.upper_body()) # or len(det.pedestrian()) 

def processImage(imgFile): 

    global connection 
    if is_person(imgFile): 
     print ("True") 
     imgFile = datetime.datetime.now() .strftime ("%Y-%m-%d-%H.%M.%S.jpg") 
     cam.capture (imgFile) 
     #with open(imgFile, "rb") as image_file: 
     # encoded_string = base64.b64encode(image_file.read()) 

    else: # Not a person 
     print ("False") 
    os.remove(imgFile) 
    sys.exit(0) 

try: 

    while True: 
     previous_state = current_state 
     current_state = GPIO.input(sensor) 
     if current_state != previous_state: 
      new_state = "HIGH" if current_state else "LOW" 
      if current_state:  # Motion is Detected 
       lock.acquire() 
       cam.start_preview() # Comment in future 
       cam.preview_fullscreen = False 
       cam.preview_window = (10,10, 320,240) 
       print('Motion Detected') 

       for i in range(imgCount): 
        curTime = (time.strftime("%I:%M:%S")) + ".jpg" 
        cam.capture(curTime, resize=(320,240)) 
        t = threading.Thread(target=processImage, args = (curTime,)) 
        t.daemon = True 
        t.start() 
        time.sleep(frameSleep) 
       cam.stop_preview() 
       lock.release() 
       time.sleep(camSleep) 

except KeyboardInterrupt: 

    cam.stop_preview() 
    sys.exit(0) 

預先感謝您。

+0

請發佈整個追溯 - 如果我們不知道錯誤發生在哪裏,我們不能幫助。 –

+0

@brunodesthuilliers整個代碼工作正常,但錯誤發生時,我添加了代碼os.system('sudo ./mjpg_streamer -i「./input_uvc.so -f 10 -r 640x320 -n -y」-o 「./output_http.so -w ./www -p 80」') – XYZ

回答

0

您在mjpg_streamer配置中遇到問題。

檢查comment #274 here

+0

我已經成功地完成了所有的mjpg-streamer配置...並且我已經在此代碼之前嘗試了os.system('sudo ./mjpg_streamer -i「 ./input_uvc.so -f 10 -r 640x320 -n -y「-o」./output_http.so -w ./www -p 80「')在另一個python腳本中工作良好 – XYZ