Strategy for accessing native camera events on Google Glass using a Service - google-glass

Background:
I have a google glass, and I am thinking on an app that can grab any/all images a user takes using the native camera, and passing those images to an online service (e.g. Twitter or Google+). Kind of like a life-blogging style application.
In my first prototype, I implemented a FileObserver Service that watches for new files in the directory that glass stores its camera preview thumbnails (sdcard/google_cached_files/). The preview files always started with t_, so once I saw a new file there, I uploaded it to my webservice. This was working very well, but in Glass XE11 this cache file was moved out of my reach (/data/private-cache).
So now, I am watching the folder sdcard/DCIM/Camera/ for new .jpg files. This works ok, but the camera is storing the full size image there, so I have to wait 5-8 sec before the image is available for upload.
The Question:
Should it be possible to have background service running on glass that can intercept the camera event, and grab the thumbnail or the full image as a byte array from the Bundle so that I don't have to wait for it to write to disk before accessing it?
I have been reading up more on android development, and I suspect the answer involves implementing a BroadcastReciever in my service, but I wanted to check with the experts before going down the wrong path.
Many thanks in advance
Richie

Yes. Implement a PreviewCallback. Same way it worked for phones, example here: http://www.dynamsoft.com/blog/webcam/how-to-implement-a-simple-barcode-scan-application-on-android/
I tested it on Google Glass and it works. In this post ( http://datawillconfess.blogspot.com.es/2013/11/google-glass-gdk.html ) I list the parameters (below the video) which the camera returns after doing:
Camera m_camera = Camera.open(0);
m_params = m_camera.getParameters();
m_params.setPreviewFormat(ImageFormat.NV21);
m_camera.setParameters(m_params);
m_params = m_camera.getParameters();
m_params.setPreviewSize(320,240);
m_params.set("focus-mode",(String)"infinity");
m_params.set("autofocus", "false");
m_params.set("whitebalance",(String)"daylight");
m_params.set("auto-whitebalance-lock",(String)"true");
m_camera.setParameters(m_params);
String s = m_params.flatten();
Log.i("CAMERA PARAMETERS", "="+s);

Related

Changing audio renderer endpoint while playing

I'm writing an audio player using Microsoft Media Foundation.
I wonder is it possible to change the playback device without re-creating the session?
IMFActivate *m_p_sink_activate;
...
m_p_sink_activate->SetString(MF_AUDIO_RENDERER_ATTRIBUTE_ENDPOINT_ID, name_device);
This doesn't take effect if the audio is already being played.
Btw, the media player provided by Microsoft.Windows.SDK.Contracts (Windows.Media.Playback.MediaPlayer) does it perfectly.
When I change m_mediaPlayer.AudioDevice, the audio stream is redirected to the assigned device immediately. So I wonder if this is also possible for MSMF.
So far I have a way could do this job,
Create a new topology which cloned from previous one.
Create new audio renderer using MFCreateAudioRendererActivate and using set string with the new audio endpoint ID add it to a topologynode;
Add the new node to new topology;
Using IMFMediaSession::SetTopology() do set new topology to play.
You could refer to MS sample TopoEdit for detail.
One side effect is that each time SetTopology cause huge memory growth.

Convert frames to video on demand

I'm working on a c++ project that generates frames to be converted to a video later.
The project currently dumps all frames as jpg or png files in a folder and then I run ffmpeg manually to generate a mp4 video file.
This project runs on a web server and an ios/android app (under development) will call this web server to have the video generated and downloaded.
The web service is pretty much done and working fine.
I don't like this approach for obvious reasons like a server dependency, cost etc...
I successfully created a POC that exposes the frame generator lib to android and I got it to save the frames in a folder, my next step now is to convert it to video. I considered using any ffmpeg for android/ios lib and just call it when the frames are done.
Although it seems like I fixed half of the problem, I found a new one which is... each frame depending on the configuration could end up having 200kb+ in size, so depending on the amount of frames, it will take a lot of space from the user's device.
I'm sure this will become a huge problem very easily.
So I believe that the ideal solution would be to generate the mp4 file on demand as each frame is created, so in the end there would be no storage space being taken as I woudn't need to save a file for the frame.
The problem is that I don't know how to do that, I don't know much about ffmpeg, I know it's open source but I have no idea how to include a reference to it from the frames generator and generate the video "on demand".
I heard about libav as well but again, same problem...
I would really appreciate any sugestion on how to do it. What I need is basically a way to generate a mp4 video file given a list of frames.
thanks for any help!

Windows Mobile C++ - Application design-type question

i have my application skeleton working as expected - it might be that somebody has a good solution to what i am trying to achieve within Windows Mobile 6.5 enviroment.
Here's what i am actually trying to do:
Application running in background ( it sends periodically network packets to office server, packets are loaded with statistics data and pushed onto the server via Winsock2 and custom made protocol ).
What 'background' means here - is an application that creates a window of 0,0 size and is minimized - i am thinking about going into the services with this, but the next thing that i require stops me today from doing this.
I need this application to be 'visible' somewhere as an icon - i already know i can't do this in the 'tray' area as stated in this post:
Windows Mobile C++ Tray Icon
Now i was trying to utilize the: SHNotificationAdd - but this is ok for a 'notification' as the name says type of thing. So it popsup and you can click to hide it - this is bad.
What i need to achieve is an icon that is visible during the application run cycle, so it flashes when there is no synchronization possible, it changes the icon when synchronization is done.
I am a bit worried it can't be done - i even tried to go and code the "Home" plug-in for this purpose, but was told that some people have themes installed and it might be that my application won't be even visible to those guys.
Now as we're going to deploy it to few places around ( 3 data centers spread across the country - around 130 people smart phones only ) - i need to be sure this application is visible even when there is a theme applied or customization done.
Any chance this can be done ?
I was kinda sure it can be done with a classic 'tray icon approach' until i found that 'tray icons' are not supported for normal applications.
If there is something i can do - i would really appreciate if somebody could shed a bit of light on this for us all please.
You'll have to move to a Windows Mobile paradigm for your app, as what you're trying to do isn't possible (as you're finding). A home screen plug in has problems if the user customizes it, and you are correct that there is no "tray". The icons in the corner (battery, signal strength, etc) are reserved for OEM use only.
My recommendation would be to actually create a visible Form for your application. Maybe it shows just some simple status info like last upload time, amount of data transferred, etc.
You then use the notifications to place a user notification during "events" such as the inability to connect (replacing your "flashing icon" idea) or when synchronization is complete (replacing your "changed icon" idea).

Creating a livestream website

We already have a functionality of Video uploading in our webapplication[built using python with Django framework]. Now we are in the process of building a livestream site where people are able to use their webcam to record the live event and it's live streamed to different participants at the sametime.
I am wondering if somebody has any idea of how to go about building a functionality like this or any pointers that would be really helpful.
I sort of looked into this same question a while ago. The dominant solution seems to be Adobes Flash Media Server. It is closed source of course and quite pricey. There are companies who run it as a service, lowering the cost of entry. And there are open source contenders, the main one being Red5, which of course also relies on flash being available on the client side.
In the future we'll probably see viable HTML5 alternatives but if you're doing something right now my feeling is that the flash route is the simplest solution and has the largest install base.
I did a video vlc record with python and it was quite simple. VLC have a stream recorder and as I know you could launch a vlc stream with a simple python code who manage the video ans the stream. I think all you need is to manage the sources and then, doing a small script who takes care about the vlc stream.
VLC stream will be launch on a different port, so I think you've to search a good server.
see vlc docs :
https://wiki.videolan.org/Documentation:Streaming_HowTo/Command_Line_Examples/
Enjoy :)
Check VLC or Flumotion...
Probably Photolab as well..
The latter one doesn't support audio...
Gee

How can I stream video from my application to the web?

I have an application that grabs video from multiple webcams, does some image processing, and displays the result on the screen. I'd like to be able to stream the video output on to the web - preferably to some kind of distribution service rather than connecting to clients directly myself.
So my questions are:
Do such streaming distribution services exist? I'm thinking of something like ShoutCAST relays, but for video. I'm aware of ustream.tv, but I think they just take a direct webcam connection rather than allow you to send any stream.
If so, is there a standard protocol for doing this?
If so, is there a free library implementation of this protocol for Win32?
Ideally I'd just like to throw a frame of video in DIB format at a SendToServer(bitmap) function, and have it compress, send, and distribute it for me ;)
Take a look at video LAN client (or VLC for short) as a means for streaming video.
As for distribution sites, I don't know how well it works with ustream.tv and similar new services.
ustream.tv works by using Adobe Flash's support for reading input from a webcam. To fake it out, you need a fake webcam driver. Looking on the ustream.tv site, they point to an application called WebCamMax that allows effects and splicing in video. It works by creating a pseudo-webcam that mixes video from one or more cameras along with other sources. Since that app can do it, your own code could do that too, although you'll probably need to write a Windows driver to get it all working correctly.