Notices


Reply
Thread Tools
Posts: 1,378 | Thanked: 1,604 times | Joined on Jun 2010 @ Göteborg, Sweden
#21
Originally Posted by azkay View Post
Thanks, though. Maybe I can optify each deb then have them in the original tar.gz to make things easier.
That would a great idea. I hope those are all the depends but my tests seem to be OK. Thank you for your efforts big time!!
 
Posts: 395 | Thanked: 509 times | Joined on Jan 2011 @ Brisbane, Australia
#22
Your post is better than mine, I forgot that I had others installed already (gtk, etcetc), so my count was just corlib and posix, ha.

I was amazed when it actually worked at full fps (dont know about over wifi, havnt tried yet).
My original version was using TCP, it ran around 17fps, but was really really laggy, smooth/lag/smooth/lag.
Second version I moved over to UDP, fixed all the problems.
Then I looked at a GUI, then stopped because it was annoying me.
Then went back again, tried windows forms because it had been ported in through mono already, then I stopped because it was ugly and annoying me. Then I went back to GTK again to try and get it working, after 2 days of things making no sense, it finally worked.

There isnt any error checking, though. The only thing that error checks is when you hit "save", it checks if the iport is splittable into ip and port, so if theres no : itll error out. If the iport doesnt connect, itll error out, but ive yet to have it error while in use. Once it starts, it has yet to stop on me.

If you want to see how the GUI made no sense to align properly, open up the smartcam-m5.exe in windows, for some reason, I had to align it like that for it to come out right on the n900.

Last edited by azkay; 2011-03-25 at 02:12.
 

The Following 3 Users Say Thank You to azkay For This Useful Post:
Posts: 1,378 | Thanked: 1,604 times | Joined on Jun 2010 @ Göteborg, Sweden
#23
It is good on wifi. I am impressed by the relatively low cpu usage at the get go.

I see that it is using gst-launch to feed to localhost - what are you doing to stream onto the network? Some mono library?

Regarding udp, does that create problems for trying to go over the WAN/internet as opposed to a LAN? If it does, perhaps there could be a udp/tcp option? I know tcp gives issues with resends --> latency etc whilst udp just streams on carelessly, but some routers kill udp traffic.

As for errors, if one closes the client smartcam then the n900 streamer crashes BUT the gst-launch process remains. Not good for battery . Would be nice if it stayed up streaming so that you could go back but of course, the port is closed so.... but the n900 process should be killed of course.
 
Posts: 395 | Thanked: 509 times | Joined on Jan 2011 @ Brisbane, Australia
#24
This is the original non-gui version,
basically, it listens on udp 127.0.0.1:5000, starts up gstreamer which streams jpegs to udp 127.0.0.1:5000, every jpeg it gets, it adds on the needed info for smartcam to use, then it tcpsends the frames to smartcam.

danielz000 was thinking we look at modifying tcpsink for gstreamer to add on the needed parts, that would take off the 8% of so usage the GUI has when its streaming:

Code:
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.IO;
using System.Collections.Generic;
using System.Diagnostics;

public class UDPListener{
	private const int listenPort = 5000;
	
	public static int Main(){
        Console.Write("Smartcam IP [XXX.XXX.XXX.XXX] : ");
        string ip = Console.ReadLine();
        Console.Write("/dev/video[0] or /dev/video[1]: ");
        string source = Console.ReadLine();

		bool done = false;
		UdpClient listener = new UdpClient(listenPort);
		IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, listenPort);
		byte[] receive_byte_array;
        Queue<byte> _buffer = new Queue<byte>();
        byte[] message = new byte[2];
        
        TcpClient _tc = new TcpClient(ip, 9361);
        NetworkStream _ns = _tc.GetStream();

        Process.Start(String.Format("gst-launch-0.10 v4l2camsrc device=/dev/video{0} driver-name=omap3cam ! ffmpegcolorspace ! video/x-raw-yuv,width=320,height=240 ! jpegenc ! udpsink host=127.0.0.1 port=5000", source));

		try{
			while(!done){
				receive_byte_array = listener.Receive(ref groupEP);
                if (receive_byte_array.Length != 0){
                    byte[] _fileData = receive_byte_array;
                    byte[] _tmpSize = new byte[4];
                    _tmpSize = BitConverter.GetBytes(_fileData.Length);

                    _buffer.Enqueue(1);
                    _buffer.Enqueue(_tmpSize[2]);
                    _buffer.Enqueue(_tmpSize[1]);
                    _buffer.Enqueue(_tmpSize[0]);

                    foreach(byte _b in _fileData){
                        _buffer.Enqueue(_b);
                    }

                    byte[] _packet = _buffer.ToArray();
                    _ns.Write(_packet, 0, _packet.Length);

                    _buffer = new Queue<byte>();
                }
			}
		}catch(Exception e){
			Console.WriteLine(e.ToString());
		}
		
		listener.Close();
		return 0;
	}
}
Ill have to look at hooking the close event, to have it kill gststreamer, if I can.

I couldve probably coded this in python, save installing all the libs and such, but Ive been trying to force myself to use c# more lately and mono being available on n900 made me want to use it.

Ill try streaming it over the internet, the quality slider should help, maybe later an optional framerate limiter.

EDIT::
I portforwarded then connected through my public iport over wifi, a little delay but worked fine (was using front cam, around half quality on the slider). Then I tried over 3g, I dont get good 3g reception here, but I dont think itll work too well anyway, maybe with a frame limiter (and if youve got lots of bandwidth to waste), it was really delayed, hitting Stop didnt close gstreamer, I think it just piles up the frames and nothing really ends up getting through after a little while, had to turn off 3g/kill smartcam-m5

If anyone wants to test some "global" streaming, from one n900 to anothers computer, let me know.

If it crashes over /dev/video1 and gstreamer is not running- but theres still the red light, the only fix ive found is to run:
Code:
gst-launch v4l2camsrc device=/dev/video1 num-buffers=1 ! fakesink
to let it reactivate/deactivate, wish I knew why it does it.

Last edited by azkay; 2011-03-25 at 02:37.
 

The Following User Says Thank You to azkay For This Useful Post:
Posts: 2,014 | Thanked: 1,581 times | Joined on Sep 2009
#25
Originally Posted by handaxe View Post
Works - well done devs!!

Here are the files needed for a minimal mono install to run smartcam:

libglib2.0-cil_2.10.4-1_armel.deb
libgtk2.0-cil_2.10.4-1_armel.deb
libmono2.0-cil_2.4.3-1_all.deb
libmono-corlib2.0-cil_2.4.3-1_all.deb
ibmono-posix2.0-cil_2.4.3-1_all.deb
libmono-system2.0-cil_2.4.3-1_all.deb
maemo-sharp_0.23-1_all.deb
mono-runtime_2.4.3-1_armel.deb

Best source of these is:

http://www.torosoft.com/mono-maemo5/.../binary-armel/

Please see thread post for my source of information: http://talk.maemo.org/showpost.php?p...2&postcount=21

Do not use the "http://go-mono.com/maemo/" repo as it is version mismatched with the run-time provided and the older runtime in the repo does not work (at least not for me).

I got errors updating the torosoft repo (ymmv) via fapman so I wget'ed the files and dkpg -i'ed 'em.
maemo-sharp is not necessary for this to function.

Now that out of the way - I have to say I am pretty damn impressed with the speed of this over wifi - even at max quality. Skype recognized it immediately and I was able to use it for other PC based apps requiring video.

Not bad - if a little large.

Have to agree with you - you do need to kill that gst-launcher process when the app closes however. Otherwise you have a 25% cpu eater just sitting there.
__________________
Class .. : Power Poster, Potential Coder
Humor .. : [*********] Alignment: Chaotic Evil
Patience : [***-------] Weapon(s): +2 Logic Mace
Agro ... : |*****-----] Relic(s) : G1, N900

 

The Following User Says Thank You to Bratag For This Useful Post:
Posts: 395 | Thanked: 509 times | Joined on Jan 2011 @ Brisbane, Australia
#26
If you hit Stop before closing it, it *should* work.
I was having problems thinking of the best way to close it.

Currently when you hit stop, it sends a # packet which gets intercepted and runs gst.CloseMainWindow(), but it doesnt seem to work every time. gst.Close() doesnt seem to close it at all, might have to Process.Start("kill " + gst.Id).

Dont know how "proper" it is to do that, though.
Also, a problem with smartcam, it doesnt seem to work on some flash based sites that use the webcam; eg; tinychat.com, it shows smartcam as disconnected or something, if you choose it anyway flash crashes.

But yeah, other than that its worked in everything else.
 
Posts: 110 | Thanked: 18 times | Joined on Dec 2009
#27
Originally Posted by azkay View Post
This is the original non-gui version,
basically, it listens on udp 127.0.0.1:5000, starts up gstreamer which streams jpegs to udp 127.0.0.1:5000, every jpeg it gets, it adds on the needed info for smartcam to use, then it tcpsends the frames to smartcam.

danielz000 was thinking we look at modifying tcpsink for gstreamer to add on the needed parts, that would take off the 8% of so usage the GUI has when its streaming:
I thought about modifying jpegenc or udpsink but the right way to do it would be creating a new smartcam plugin to sit between jpegenc and udpsink.

Unfortunately it'll take me a while to read through the gstreamer docs for creating plugins as I'm a bit short of time.
 

The Following User Says Thank You to danielz000 For This Useful Post:
Posts: 1,378 | Thanked: 1,604 times | Joined on Jun 2010 @ Göteborg, Sweden
#28
@azkay: if you don't mind, what is the advantage in using driver=omap.. with gst-launch? I could not see any reduction in cpu use, in fact if anything it increases it, as "omap3camd" kicks in, offsetting any reduction in gst-launch's cpu use. Does hw accel improve framerate?

Originally Posted by azkay View Post
If you hit Stop before closing it, it *should* work.
I was having problems thinking of the best way to close it.
In my testing stop works just fine, the issue arises when the receiver disconnects, smartcam goes away without tidying up. Ideally, the gui should not disappear if tcp crashes, but revert to the gui with the "stop" button changed to "start". I assume this is what you meant by there being no error checking?

Last edited by handaxe; 2011-03-25 at 15:32.
 
Posts: 41 | Thanked: 37 times | Joined on Jan 2011 @ Guatemala
#29
Thanks works very very well, thank you so much for the app great work
 
Posts: 395 | Thanked: 509 times | Joined on Jan 2011 @ Brisbane, Australia
#30
Originally Posted by handaxe View Post
@azkay: if you don't mind, what is the advantage in using driver=omap.. with gst-launch? I could not see any reduction in cpu use, in fact if anything it increases it, as "omap3camd" kicks in, offsetting any reduction in gst-launch's cpu use. Does hw accel improve framerate?
If you dont use omap driver then the video has a noticable green tint.
Dont know how to use hardware acceleration, there was a hardware accelerated jpeg encoder for gstreamer in the past, but I cant find it anymore. I dont think it would improve framerates any higher, I think around 30 is the hardware limitation of the camera, I could be wrong.
Hardware acceleration would be for less cpu usage I would think.
 

The Following User Says Thank You to azkay For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 03:11.