Arduino Forum

Products => Arduino Yún => Topic started by: Nico91 on Nov 11, 2013, 01:37 pm

Title: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: Nico91 on Nov 11, 2013, 01:37 pm
Hi,

i would like to connect an ip cam to my Arduino Yun ethernet port. Next i would like to connect my iPhone to the wifi Access Point of the Yun and watch the live video from my iPhone.

To do this I need to configure the arduino as a router. How can I do that?

Thank You.
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: lucad79 on Nov 11, 2013, 04:39 pm
Hi Nico,

it could be possible, but why using a Yun for a similar application, where a simple router in "wifi client" mode works fine and it's cheaper? For example a TL-WR702N:
http://www.lucadentella.it/2012/12/09/enc28j60-e-arduino-11/
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: Nico91 on Nov 11, 2013, 05:02 pm
Thank you for the reply.

I need this configuration because i want to send URL command to the Yun using iPhone.  For example if i want build a rover with video stream i use ip cam to make the video and Arduino to move the rover.
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: lucad79 on Nov 11, 2013, 10:08 pm
Hi Nico

I read some documentation from OpenWRT project... what you're looking for is something described here:
http://wiki.openwrt.org/doc/howto/clientmode

as you may read, it's not an "easy" setup...
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: Nico91 on Nov 12, 2013, 12:23 am
So if i want watch my live video through Arduino using my iPhone i need to do this setup? is there other way?

Thank you.
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: AllSystemGO on Nov 12, 2013, 01:19 am
For my setup, I use this: http://forum.arduino.cc/index.php?topic=188690.0

and then I open Safari and browse to http://the ip:8080/?action=stream

Hope it help and that's what you are looking for
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: Nico91 on Nov 12, 2013, 01:33 am
But the configurations that are shown in this discussion you need to use a usb webcam or ip cam?

He says that the video has a delay of 4 seconds, but with the ip cam it should be in real time.

Thank You.
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: AllSystemGO on Nov 12, 2013, 03:59 am
Yeah but you need to read the complete posts. At the end he uses the mjpg-stream and it works really good. I tried it and I have a 1/2 a sec of delay. And I use a USB Cam, Microsoft HD-3000
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: lucad79 on Nov 12, 2013, 10:24 am
Guys,

an IP Cam is a cam with an ethernet interface... so the setup using an USB webcam can't work.
My suggestion is to provide an external solution to "transform" the IP Cam in a wifi Cam, like the router I suggested before.
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: Nico91 on Nov 12, 2013, 10:45 am
Hi,

i can also use a USB webcam if this configuration has very little delay. How long can this configuration continue to operate ?

If i use a webcam without HD can i reduce the delay?

The ip cam that i have have also wifi configuration, but it is the same problem, arduino is not configured like a router so if i connect the cam to Arduino and my iPhone to Arduino i can't watch the video from iPhone.  Maybe i could use an external mini router but if the webcam configuration has a very little delay it is the best configuration also for the dimension.

Thank You.
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: AllSystemGO on Nov 12, 2013, 02:20 pm
Like I said there is a 1/2 a sec delay using a HD-3000 at 5 FPS, I don't think that the HD is doing the delay here.
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: Nico91 on Nov 12, 2013, 02:43 pm
Can i reduce the fps to reduce delay?

I don't understand some command:

-SSH into OpenWRT
-Install either the UVC driver (if not already installed) e.g. opkg install kmod-video-uvc
    where i need to install them? and how?

Thank You.
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: AllSystemGO on Nov 14, 2013, 06:24 am
5 FPS is the lowest you can go I think. But you could try it and test it for yourself.

I know the steps are a bit tricky cause I had a hard time understanding too. So here goes

Quote
SSH into OpenWRT

This mean you need to connect to the Yun SSH interface, so open putty for windows, and SSH to the IP of the YUN. So in my case it was ssh 192.168.240.1. That's going to get you in the linux part of the Yun, or as they call it the OpenWRT.

Quote
Install either the UVC driver (if not already installed) e.g. opkg install kmod-video-uvc
    where i need to install them? and how?

That's the hardest part to understand. What you need to do is get the package from here https://www.dropbox.com/sh/6nv5f2datb3n2ps/nj-z27B6i1 (https://www.dropbox.com/sh/6nv5f2datb3n2ps/nj-z27B6i1) download all the ipk to your desktop. Then you can put them on a MicroSD. Take that MicroSD and put it in the Arduino.

2- Then you need to mount the MicroSD, you need to type those commands in putty while connected to the openWRT. The commands you need to type are in bold

- add your micro sd card (it should appear as /dev/sda1 by default)
- Create a folder or mount point /mnt/sda1 (mkdir /mnt/sda1)
- mount your sd card - mount /dev/sda1 /mnt/sda1

3- Then you need to install those package. So you need to go in the /mnt/sda1 and install all the packages. And you do it like that : opkg install mjpg-streamer.ipk.

So start by the first one and go down the list. Don't worry if you install one package and you get an error message saying that you need another package before. Just install the Pre-Requisit and after re-install the one that fail. In the end all the package should install.

4- Once all that's done type mjpg_streamer -i "input_uvc.so -d /dev/video0 -r 640x480" -o "output_http.so -p 8080 -w /mnt/share"

and you should be all set.

Quote

- Open your web browser to: http://arduino.local:8080/?action=stream for a stream or http://192.168.1.1:8080?action=snapshot for a single snappy
- Enjoy


Hope it helps
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: federicofissore on Nov 14, 2013, 09:18 am

2- Then you need to mount the MicroSD, you need to type those commands in putty while connected to the openWRT. The commands you need to type are in bold

- add your micro sd card (it should appear as /dev/sda1 by default)
- Create a folder or mount point /mnt/sda1 (mkdir /mnt/sda1)
- mount your sd card - mount /dev/sda1 /mnt/sda1


Why do you need to do that? Isn't the yun doing that automatically? It should. AFAIK, if it doesn't, doing it manually shouldn't work either.
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: Nico91 on Nov 14, 2013, 10:01 am
Thank you!!

When i need to connect to the Yun interface i need to type the command "ssh ip" on my OSX terminal and all works fine? I can know the ip connecting to my Yun and open the network settings?

Sorry for the question but I am an iOS developer and i don't know this kind of programming.

Thank you very much!
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: federicofissore on Nov 14, 2013, 11:26 am
If your yun is connected to your computer, you can upload YunSerialTerminal example, open serial monitor and get the same linux prompt you'd get with ssh
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: Nico91 on Nov 14, 2013, 12:47 pm
I used this command on my OSX terminal an it works:      SSH -X root@arduino.local
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: Nico91 on Nov 14, 2013, 07:39 pm
when i try to install i get this error :

root@Arduino:/mnt/sda1/arduino# opkg install fswebcam_20110717-1_ar71xx.ipk
Installing fswebcam (20110717-1) to root...
Collected errors:
* satisfy_dependencies_for: Cannot satisfy the following dependencies for fswebcam:
*    libgd *
* opkg_install_cmd: Cannot install package fswebcam.

I installed all other.
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: lucad79 on Nov 14, 2013, 09:08 pm
Hi

are you installing the ipk packages from the SD because of your Yun is not connected to Internet?
Otherwise it's a really better solution to let opkg download them (and resolve all the dependances) for you...
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: Nico91 on Nov 14, 2013, 10:03 pm
I put all the file on my SD , next i connected the arduino using ssh with OSX terminal. Next i type the command "opkg install" for all the files.  All works fine but fswebcam no.
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: AllSystemGO on Nov 15, 2013, 05:20 am
I don't think it's really important it should work without it.
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: Nico91 on Nov 15, 2013, 10:30 am
when i type last command i get this :

i: Using V4L2 device.: /dev/video0
i: Desired Resolution: 640 x 480
i: Frames Per Second.: 5
i: Format............: MJPEG
ERROR opening V4L interface: No such file or directory
Init v4L2 failed !! exit fatal
i: init_VideoIn failed
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: Nico91 on Nov 15, 2013, 10:35 am
I didn't connected webcam Ahahahah!!!! thank youuu now it works fine!


Now how can i run this command from Arduino sketch?
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: AllSystemGO on Nov 15, 2013, 02:46 pm
No actually you need to go in the web console of the arduino and select the advance user. Go down in the advance menu and you'll see what does the openwrt starts, like WIFI, you can put the command in there and it will be executed when you boot the arduino.

Sorry for the general terms here as I don't have my arduino here and I just can't remember. If ever it doen't help I'll let you know exactly where to go tonight.
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: Nico91 on Nov 15, 2013, 03:37 pm
The webcam works fine, but sometimes it freezes for a few seconds and then starts again. Is it normal? how can I solve it?

With Microsoft hd 3000 i get problem, but with Logitech c170 (VGA quality) it work very well. I think that the VGA is better than HD for speed.
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: AllSystemGO on Nov 16, 2013, 03:16 am
For me using the HD-3000 I never had a problem yet. I use it to control my rc car and it works well. I'll give the logitech a try too just for fun.

Did you figure out where to put the command to make it start at bootup?
Title: Re: Connect ip cam to Arduino Yun and watch live video from iPhone
Post by: Nico91 on Nov 16, 2013, 11:03 am
Maybe my hd3000 have a problem itself.

Yes i put the command at boot up, it takes few second to configure.

Now i can develop my iphone app.

Thank you.