Trouble with False Alarms

Benjamin has recovered well from his surgery (scoliosis correction) and is feeling quite his usual self again today after a good trip out to the football, with much bouncing around his bedroom sorting things (no sound on this video – imagine loud ‘Haaa’ sounds!).

This behaviour is really challenging to differentiate between this and a seizure using the simple algorithm we use in the pebble watch, so he keeps setting off his seizure detector alarm.   While it’s nice to know he is feeling better, the beeps get annoying and you start to ignore them if they go off too often, so I had to do something about it….

I have had a look at the alarm log and in all cases the spectral power in the 5-10Hz region of interest is well over the threshold level, but the ratio of the power in the region of interest to the whole spectrum is borderline – the ratio alarm level is set to 30 by default (=3.0 ratio) and he is generating a ratio of between 3 and 4.   This means that a relatively minor change to the ratio alarm level could solve the problem without compromising the detection capability.   I have increased the ratio threshold to 40 (=4.0 ratio).  At this level it just avoids going off with the sorting movements, but still alarms easily with a seizure-like shaking of the arm without other movement going on too.   Will test for a while and see how it goes.

I think I’ll write a page describing what the settings are and how to tune them in case other people have trouble….

[Note, I think I had done this before (but maybe not increased the ratio threshold as far as 4.0), but re-installed the app and lost my settings – should have written them down!].

Compatibility with Pebble Time and Pebble Round

A user has reported problems trying to use OpenSeizureDetector with a Pebble Time watch.

I have re-compiled the watch app using the latest Pebble tools which should have made it compatible with Pebble Time and Pebble Round watches as well as the original Pebble.   This new version is published on the Pebble App Store as Version 1.2.

This version continues to work normally on an original Pebble, but should also run on one of the newer designs.  Note that I have not tested it on a Pebble Time or Pebble Round though, only an emulator, so please feed back any experience with it on these devices!

No changes to the Android app were required.

Please let me know if you encounter any problems after this change, and I can revert back to the previous version.

Graham (graham@openseizuredetector.org.uk)

Android Version of ‘BenTV’ Camera Viewer

Before we had the pebble watch seizure detector, I had set up a video camera system in the house so we could keep an eye on Benjamin to see he is ok when he is up in his bedroom (he is autistic so likes to lock himself in there and doesn’t like visitors!).  The current system uses a WansView network (IP) camera and some Raspberry Pi based monitors in the living room, dining room etc. to see and hear what is happening.

I have always liked the idea of having a mobile phone or tablet computer version of the monitor that we can take with us if we are in a different room, the garage, garden etc.  I have had a couple of attempts at writing it, and always failed, so have been doing more investigations to see what is wrong.

There is a minimalist Android app on the OpenSeizureDetector Github repository which will open an RTSP stream from the camera and display it on screen with audio, using the Android MediaPlayer library which is part of the Android system.

The problem is that I kept getting an error:

E/MediaPlayer: Error (1,-2147483648)

which is not awfully helpful – error 1 means ‘Unspecified MediaPlayer Error‘, and all I got was a blank screen.

I tried all sorts of combinations of RTSP url’s and authentication methods, and different video stream sizes and bit rates, in the hope that that would help.   See the Troubleshooting_log.txt file in the repository.  Nothing Did – always got error 1 and a blank screen….

Then I remembered that I have an old Y-Cam Knight video camera in the attic.  I set that up and pointed the app at its rtsp video stream (rtsp://guest:guest@192.168.1.18/live_mpeg4.sdp)…and I got video and audio – success!

Rapidly decided to scrap Wansview camera and buy another Y-Cam one…But Y-Cam don’t do IP Cameras any more, just ‘Cloud Cameras’ which are apparently different and only transmit when they detect movement, which is no use for me….

So at least I know it is not my software, it is something to do with the wansview camera.   As a fall back I have ordered a D-Link camera, which I have seen reports of working from someone called Josh Smith, and on which I based my minimalist test app.

But that would be giving up, so I’d like to understand what is wrong with the stream from the wansview camera.

From my experiments, Error 1 could come from an RTSP authentication fault, but I don’t think that is it, because the same URL works with openRTSP from my laptop.   So another possibility is a audio/video format issue.   You can use openRTSP to download the raw audio and video streams separately –

openRTSP "rtsp://guest:guest@192.168.1.25/12"

This yields a video-H264-1 and an audio-PCMA-2 file.   You can now use ffmpeg to create a .mp4 container containing either the video file alone or the video and audio combined.

Just video file:

ffmpeg -f h264 -i video-H264-1 -vcodec copy wansview_video.mp4

openRTSP can create a combined audio/video one during the download with:

openRTSP -4 "rtsp://guest:guest@192.168.1.25/12" > audio_video.mp4

But the resulting file crashes mplayer and gives an “unknown error” in vlc.  So I suspect it might be the audio format that is giving the trouble – the ycam camera used amr audio format, not pcma.

A quick check confirmed that the wansview_video.mp4 file plays ok when copied into the res/raw folder of the app and the software modified to play that, rather than the RTSP stream.   So, I think that Android is playing the h264 video ok (which it should according to the Supported Media Formats page.   The problem is probably an issue with the PCMA audio format – PCM is supported, but this must be different to PCMA…

This means that I am not going to be able to write a nice simple App to play the audio and video using the provided Android MediaPlayer library – if I want it, I will have to be cleverer to deal with the audio.  I think the options are:

  • Write it all from scratch (major undertaking!)
  • Use the ffmpeg library that has been ported to Android
  • Use the Gstreamer library that has been ported to Android

I am a bit suspicious about trying to use ffmpeg, as this didn’t seem to like the PCMA on my laptop (although dolphin player, which is based on ffmpeg plays the openRTSP created .mp4 file ok), so maybe Gstreamer is the way to go.   There is an Open Source RTSP viewer available that is based on gstreamer (rtspviewer), or possibly (rtspplayer).

So I’m going to have to learn a bit more about native apps on Android – I had hoped that making a video player would be trivial!