简体   繁体   English

OpenCv使用IP摄像头照片

[英]OpenCv using an IP camera photo

I am trying to work in opencv with a photo that I took with the Android IP camera (http://192.168.0.10:8080/shot.jpg), but it doesnt work, I get a blank window. 我正在尝试使用Android IP摄像头拍摄的照片在opencv中工作(http://192.168.0.10:8080/shot.jpg),但它不起作用,我得到一个空白窗口。 I tried with another image (http://images2.wikia.nocookie.net/_ cb20110420175105/agallas/es/images/thumb/1/11/Agallas-el-perro-cobarde-125 (1).jpg/640px-Agallas-el-perro-cobarde-125_(1).jpg) and It works perfectly. 我尝试了另一张图片(http://images2.wikia.nocookie.net/_ cb20110420175105 / agallas / es / images / thumb / 1/11 / Agallas-el-perro-cobarde-125 (1).jpg / 640px- Agallas-el-perro-cobarde-125_(1).jpg),它完美无缺。 Why doesn't it work with the photo taken with the ip camera? 为什么它不适用于使用ip camera拍摄的照片?

  import sys, cv
  import numpy as np
  #photo = "http://images2.wikia.nocookie.net/__cb20110420175105/agallas/es/images/thumb/1/11/Agallas-el-perro-cobarde-125_(1).jpg/640px-Agallas-el-perro-cobarde-125_(1).jpg"
  photo = "http://192.168.0.10:8080/shot.jpg"
  img=cv.CaptureFromFile( photo )
  while True: 
    frame = cv.QueryFrame(img)
    cv.ShowImage('Foto',frame)
    if cv.WaitKey(30)==27:
         break 

Both pictures have the same dimensions 两张图片都有相同的尺寸

This could be not a very efficient way to solve my problem, but it works. 这可能不是一个非常有效的方法来解决我的问题,但它的工作原理。

import urllib
import cv 

urllib.urlretrieve("http://192.168.0.10:8080/shot.jpg", "foto.jpg")
imagen=cv.LoadImage('foto.jpg')
cv.ShowImage('Image',imagen)

Here's some code that I have working to stream from my phone running Android IP Camera, using Andrea Diaz's idea and python with opencv2... 这里有一些代码,我正在使用安德里亚迪亚兹的想法和使用opencv2的python从运行Android IP Camera的手机中传输...

import cv2
import urllib

while True:
    urllib.urlretrieve("http://192.168.0.10:8080/shot.jpg", "foto.jpg")
    src_image = cv2.imread('foto.jpg', 0)
    cv2.imshow('Viewer',src_image)
    # read user keyboard for 5ms, and break on any keypress.    
    if (cv2.waitKey (5) != -1):
        break;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM