0

I'm trying to access my phone camera using IP Webcam android app. I'm programming Pi using my laptop via Remote Desktop Connection with a static IP set for Pi. Also I tried to stream webcam from Pi's chromium browser showing connection timed out. I'm able to stream the cam from my laptop's Firefox browser.

Code given below is throwing some error.

import urllib
import cv2
import numpy as np

url='http://192.168.225.51:8080/shot.jpg'

while True:
    imgResp=urllib.urlopen(url)
    imgNp=np.array(bytearray(imgResp.read()),dtype=np.uint8)
    img=cv2.imdecode(imgNp,-1)

    # all the opencv processing is done here
    cv2.imshow('test',img)
    if ord('q')==cv2.waitKey(10):
        exit(0)=

The following error is shown

Traceback (most recent call last):
  File "/home/pi/Desktop/New.py", line 8, in <module>
    imgResp=urllib.urlopen(url)
  File "/usr/lib/python2.7/urllib.py", line 87, in urlopen
    return opener.open(url)
  File "/usr/lib/python2.7/urllib.py", line 213, in open
    return getattr(self, name)(url)
  File "/usr/lib/python2.7/urllib.py", line 350, in open_http
    h.endheaders(data)
  File "/usr/lib/python2.7/httplib.py", line 1038, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 882, in _send_output
    self.send(msg)
  File "/usr/lib/python2.7/httplib.py", line 844, in send
    self.connect()
  File "/usr/lib/python2.7/httplib.py", line 821, in connect
    self.timeout, self.source_address)
  File "/usr/lib/python2.7/socket.py", line 575, in create_connection
    raise err
IOError: [Errno socket error] [Errno 110] Connection timed out
0

Also I tried to stream webcam from Pi's chromium browser showing connection timed out.

This is the core of your problem: the Pi has no access to the camera over the network. You need to diagnose your network and find out what's wrong. I would start by running

traceroute 192.168.225.51

to see how data is routed.

  • It's showing the following things only. traceroute to 192.168.225.51 (192.168.225.51), 30 hops max, 60 byte packets 1 * * * 2 * * * 3 * * * ......... – Shyam Mohan Mar 28 '18 at 13:33
  • What's your Pi's IP address? How does the routing table (route -n) look like? – Dmitry Grigoryev Mar 28 '18 at 14:12
  • Pi's IP is 192.168.137.55 Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.43.1 0.0.0.0 UG 303 0 0 wlan0 192.168.43.0 0.0.0.0 255.255.255.0 U 303 0 0 wlan0 192.168.137.0 0.0.0.0 255.255.255.0 U 202 0 0 eth0 I'm not able to paste above info in correct format please view in editor – Shyam Mohan Mar 28 '18 at 14:47

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.