maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Nokia N800 (https://talk.maemo.org/forumdisplay.php?f=25)
-   -   Webcam Viewer app for N800? (https://talk.maemo.org/showthread.php?t=26958)

s2k 2009-02-18 10:09

Webcam Viewer app for N800?
 
Does anyone know of a webcam viewer app that would allow me to view a IP based webcam in fullscreen on the N800? The webcam provides a jpeg stream of images and I'd liek to be able to view it on the N800 instead of the desktop for a portable viewer if possible.

jolouis 2009-02-18 15:43

Re: Webcam Viewer app for N800?
 
The webcam doesn't provide a web interface to let you view it? Do some searching around, I believe I've seen others in the past talk about using MPlayer to do this, but can't be 100% certain now...

s2k 2009-02-18 16:41

Re: Webcam Viewer app for N800?
 
The webcam has an interface but it is ActiveX or Java based to handle the refreshing and related, which the N800 cannot do unless I've mised something.

Was looking for an app that could handle it directly to do the refreshing of the images.

s2k 2009-02-18 17:27

Re: Webcam Viewer app for N800?
 
I don't see anything in mplayer to handle it nor do I see any webcam specific apps. :(

MattZTexasu 2009-02-18 20:05

Re: Webcam Viewer app for N800?
 
I had an interest in this too. I found a random mjpg webcam stream http://77.46.140.219/axis-cgi/mjpg/v...=1234987014475

I know that firefox has native support for it, and it works on the desktop. but the stream doesn't exactly work well on the NIT. and neither mplayer nor any other player on the NIT i tried would play it.

s2k 2009-02-18 20:11

Re: Webcam Viewer app for N800?
 
I setup a simple JS function that causes a page refresh that shows the image every second. It works fne on PC. On NIT it runs for a a few seconds then stops as if the browser times outthe script, click the screen and it reactivates.

Anyone know how to prevent thsi from hapening, ie so it doesn't stop the JS refresh?

MattZTexasu 2009-02-18 20:34

Re: Webcam Viewer app for N800?
 
Actually, I was making a mistake. It works find in the browser on the NIT, you just have to embed the image in an html file. No JS necessary.

Save this in a file called webcam.htm
Code:

<html>
<body style="margin:0;padding0;background-color=black;">
<img src="PUT_URL_TO_YOUR_MJPEG_STREAM_HERE" height="480" />
</body>
</html>

the height="480" part will force the image to fill the whole height of the browser page. if it looks funny, you can adjust it or add a width="xx" attribute (replace the "xx" with proportional value to the height).
Make the browser full screen and you got what you want.

MattZTexasu 2009-02-18 20:36

Re: Webcam Viewer app for N800?
 
Quote:

Originally Posted by s2k (Post 265433)
I setup a simple JS function that causes a page refresh that shows the image every second. It works fne on PC. On NIT it runs for a a few seconds then stops as if the browser times outthe script, click the screen and it reactivates.

Anyone know how to prevent thsi from hapening, ie so it doesn't stop the JS refresh?

instead of refreshing the page, only refresh the image element. Here's how:
Code:

<html>
<head>
    <title>Untitled Page</title>
    <script type="text/javascript">
        function grabImage() {
            var imgFrm = document.getElementById('imageframe');
            var img = document.createElement("img");
            img.setAttribute('src', 'http://77.46.140.219/axis-cgi/mjpg/video.cgi?resolution=CIF&dummy=1234987014475');
            imgFrm.removeChild(imgFrm.firstChild);
            imgFrm.appendChild(img);
            setTimeout(grabImage, 10000);
        }
    </script>
</head>
<body onload="grabImage();">

<div id="imageframe"><img /></div>

</body>
</html>

NOTE: if you have to refresh the image, it's not really a mjpeg stream. It's just an image that get's updated at an interval. an mjpg stream should update itself without any JS in firefox on the Desktop or on the NIT's browser.

s2k 2009-02-18 20:45

Re: Webcam Viewer app for N800?
 
http://www.ajaxcam.com is what i'm using.

it "seems" to run fine if I don't go fullscreen mode. Could something else be taking focus in the background and stopping the script perhaps?

s2k 2009-02-18 20:54

Re: Webcam Viewer app for N800?
 
It seems it may have been the mail notifications taking focus from the browser in fullscreen mode. Turned it and chat off and it "seems" to now be working. Still testign though. The posted script above I couldn't get to work at all even locally, it never refreshed it seemed.

MattZTexasu 2009-02-18 21:10

Re: Webcam Viewer app for N800?
 
the ajaxcam guy is doing exactly what I posted. I just left off the cache busting random number (the Math.Random part) that he uses because it doesn't work with all feeds. It shouldn't be necessary with an IP camera; but I guess it is with the one you're using.

perhaps if you put a textbox on the page and give it focus, the browser will maintain focus and keep refreshing.

endorphinum 2009-02-18 23:00

Re: Webcam Viewer app for N800?
 
Is it a webcam taht ANYONE could or should see?
I am just asking because if yes, then i could make a mojocafe.net
widget out of it!

s2k 2009-02-18 23:56

Re: Webcam Viewer app for N800?
 
Quote:

Originally Posted by endorphinum (Post 265498)
Is it a webcam taht ANYONE could or should see?
I am just asking because if yes, then i could make a mojocafe.net
widget out of it!


no, private

s2k 2009-02-19 10:38

Re: Webcam Viewer app for N800?
 
Well I had thought it was working with email notifcations off, but turned it on today and back to same issue it appears, seems as if the script just stops running in the browser for some reason. Not sure why it works sometimes and not others now :-\ Something must be takign focus or an issue with browser itself.

s2k 2009-02-19 11:00

Re: Webcam Viewer app for N800?
 
I guess maybe the N800 needs to go back to collectign dust at this point if a simple script wont work consistently and no other webcam viewer options :(

jolouis 2009-02-19 13:51

Re: Webcam Viewer app for N800?
 
If it is indeed an MJPEG stream, then you can use mplayer as I'd originally suggested:

http://www.lavrsen.dk/twiki/bin/view...gStreamViewing

If it's just a sequence of JPEG images that you must manually refresh, then your browser approach is probably the easiest solution; try turning the setTimeout value up so that it's refreshing a little less often and see if that has any effect.

s2k 2009-02-19 14:14

Re: Webcam Viewer app for N800?
 
It is just a series of JPEGs. The script finally worked yesterdya when I tyrned off email notifications, but today after a restart it doesn't work at all No idea why.

s2k 2009-02-19 14:37

Re: Webcam Viewer app for N800?
 
It appears to be perhaps some weird glitch related to the screen settings to auto turn it off. Even though I have it set to always be on when charging, it seems to stay lit but appear disabled. I reduced the time settings in there to 30 seconds and the website seems to freeze around that time. Only a guess at this point :-\

Edit - seems to be the case, set to 1 min on display settigns and web froze after 1 min, same at 30 seconds setting.

Any ideas why this would happen when it is plugged in and anyway to override?

jolouis 2009-02-19 19:57

Re: Webcam Viewer app for N800?
 
My guess based on that feedback would be that the browser is doing power saving by stopping anything that it's running after the given idle time, whether the screen is "on" or not. (Remember screen on != idle or active).

Perhaps a better approach would be to build a simple python application that periodically loads the given image file and displays it on screen... shouldn't be very hard to do using something like pygame.
Hopefully somebody with a bit more python experience steps up here, but if not I'll see if I can throw something basic together at some point this evening...

s2k 2009-02-19 20:25

Re: Webcam Viewer app for N800?
 
Turned out it was the screen display setting. Set them to 24 hours instead of 5 mins and works fine.

jolouis 2009-02-19 21:15

Re: Webcam Viewer app for N800?
 
Nice, though remember you'll have to click on your tablet once every 24 hours! lol

Anyways, if you're still looking for an alternative, I threw together a VERY basic python app that will do the same sort of thing (without needing the browser)
Code:

#!/usr/bin/python2.5

import urllib2
import os, sys
import pygame
from pygame.locals import *


def updateImage():

        tempFile = os.tempnam();
        #
        # find yourself a picture on a web page you like
        #
        # (right click on the picture, look under properties and copy the address)
        #
        picture_page = "http://www.google.com/intl/en/images/logo.gif"
        #
       
        #
        # open the web page picture and read it into a variable
        #
        opener1 = urllib2.build_opener()
        #
        page1 = opener1.open(picture_page)
        #
        my_picture = page1.read()
       
        #Save to temp file
        #
        fout = open(tempFile, "wb")
        #
        fout.write(my_picture)
        #
        fout.close()
       
       
       
        screen = pygame.display.get_surface()
       
        myImage = pygame.image.load(tempFile).convert()
       
        screen.blit(myImage, (0,0))
        pygame.display.flip()
       
        os.remove(tempFile);

def main():
        #init PyGame
        pygame.init()
        window = pygame.display.set_mode((700,400))
       
        UPDATE_EVENT = pygame.USEREVENT + 1
       
        updateImage()
        pygame.time.set_timer(UPDATE_EVENT, 1000)
       
        while True:
                event = pygame.event.wait()
                if event.type == QUIT:
                        sys.exit(0)
                elif event.type == UPDATE_EVENT:
                        pygame.time.set_timer(UPDATE_EVENT, 0)
                        updateImage()
                       
                        pygame.time.set_timer(UPDATE_EVENT, 1000)
               
        #loop.run()

if __name__ == "__main__":
    main()

Just change the picture_page variable to whatever the URL of your webcam thing is and you should be good to go. It's not fancy and the coding is probably horrendous by most standards, but it should work regardless of display settings/etc.

s2k 2009-02-19 22:32

Re: Webcam Viewer app for N800?
 
Thanks for the code, but the webpage seems to be working now and with how I have it sized it basically is a fullscreen image in zoom mode, which is exactly what I wanted.

Makes good use again of my N800 at least. Nest I'll have to add some overlayed data for time, temps, etc to make it a mini info hub perhaps.


All times are GMT. The time now is 15:08.

vBulletin® Version 3.8.8