Open piecam opened 9 years ago
however, cpu wise, it looks MotionPie always is at 90 or high 80% with motion 40-50%, motioneye 40%. If I use motion-mmal, the total cpu is about 70%.
It looks like RPI wEb interface, the cpu is not that much, even using apache, which considered heavy, comparing to Nginx, lighthttpd, etc. Maybe python takes much of CPU??
I'll let you guys expert to tell. thanks.
first one is minibian distro with rpi web interface, apache looks like using more cpu actually. 2nd is the with motionpie with one pi cam. 3rd is the motionpie with pi cam + usb cam.
This python helper has now been superceded by the work I have been doing on my fork of silvan melchiors's original project. Check out the RPi_Cam_Web_Interface repository for latest stuff.
The piecam and silvan's camera projects took 2 fairly different approaches to the requirements and it is not easy (or even possible) to blend them together.
piecam is a general purposes webcam / Pi camera using motion as the basic recording / detection mechanism. This allows it to straightforward pre-capture etc. but the penalty is it can't really do it at high resolution or high frame rate as the motion detection algorithm becomes to CPU onerous.
RPi Cam as here is dedicated to the Pi camera and using the mmal interface (as used in RaspIvid) to give high frame rate high resolution recording up to full HD. To do the motion detection it also feeds a low res mjpeg stream to do motion detection. As the motion events are then used to start and stop the high res recording then things like pre-capture are not supported.
I am continuing to enhance the basic RPi Cam in a number of different directions including a recently added scheduling facility.
Other possible areas are
Does motion ask raspMJPEG to do the video or stills? How do you define those, in motion.conf/thread1.conf?
Great explanation and insides.! tks
motion is started and stopped by the web interface. When it is running then when it detects movement then it does whatever on_event_start in motion.conf says. Likewise on_event_end defines what to do when movement stops.
For RPi Cam these just send a command to a named FIFO pipe which raspimjpeg is listening on. So by default on_event_start does echo 'ca 1' > /var/www/FIFO The ca 1 is the start video capture command for raspimjpeg
Manual recording, stills and putting into time-lapse are done by the web pages sending in equivalent commands to the FIFO as well.
thanks a lot for explaining these. It would help if you can provide a few examples, like,
thanks for your time.
btw, I am a bit confused.
when I am going to do a new install, do I go with this http://www.raspberrypi.org/forums/viewtopic.php?f=43&t=63276, or with yours https://github.com/roberttidey/RPi_Cam_Web_Interface?
Or, are they same now? tks.
The first link is the silvan melchior's original code for this. The second is my modified fork of this. That means it is largely based on the original but I have modified and added stuff mainly around the browser interfaces. These give in my view a better preview display, direct access to motion set up, and scheduled automation.
It is easy to move between these as the Installer script has a remove option allowing one to rrapidly move between versions or update if changes are made.
HI robert, I have a few questions and hope that you can help out.
out put from Pi B+: root@raspberrypi:~# ls /dev/video0 /dev/video0
root@raspberrypi:~# cat /etc/modules snd-bcm2835
root@raspberrypi:~# cat /boot/config.txt gpu_mem=128 start_x=1
Out put from pi A+, root@raspberrypi:~# ls /dev/vi ls: cannot access /dev/vi: No such file or directory
root@raspberrypi:~# cat /etc/modules snd-bcm2835
root@raspberrypi:~# cat /boot/config.txt gpu_mem=128 start_x=1
Will it affect some functions? Do I have to put video module in /etc/modules,?
These may be noobs question. If you can help out, I really appreciate it.
Thanks in advance.
HI robert, I used minibian which has just root user. Once I get your fork installed, I dont see INSTALL
There are 3 python files, RaspiCam.py and two support libraries which should all be placed in /home/pi/python
directory.
Should I create a pie user?
thanks
This may be no longer valid with your new fork? tks
You are using the wrong repository. If you look at the README then you will see that I have moved on to putting everything in a proper fork of RPi_Cam. THis then includes all the original code plus my modifications. Just go up a level from this repository then select the RPi_Cam one. When you retrieve and unzip that one then it will look like the original with an install script.
Not sure about model A, I'll have to think about that, the memory may be an issue.
3.1 Yes that is right to default motion on. If you are using my version then you can achieve the same thing by using the scheduler and including md 1 as a command in each of the day periods where you want motion detection on.
3.2 You can change the motion commands from ca 1 and ca 0 to say tl 20 and tl0. Then when motion is detected then it says use time lapse (1 picture every 2 seconds, 20 is in 0.1sec units) These time lapse pictures are high resolution.
3.3 When it does video capture it uses the settings from the web page so select the hd from there.
3.4 No. The basic camera is either in video mode or stills. However, you can extract quality stills from the video using say ffmpeg.
3.5 Short clips are probably caused by motion deciding the movement has stopped which then stops the recording. I am working on some enhancements in this area to give more flexibility on this. If you are using my scheduler you can already achieve a similar effect by setting the motion end commands to empty and then using the maximum capture time setting. So for example if this was set to 20 seconds, then motion would start a recording, the end of motion would be ignored but the scheduler would then send an off command after 20 seconds. With that technique all recording s would be 20 seconds long.
HI Robert,
Please forgive my ignorance. Can you kindly know which one should I use? https://github.com/roberttidey/RaspiCam
or https://github.com/roberttidey/RPi_Cam_Web_Interface
I am a bit confused with all these. I guess you mean first one. However, just check for sure. Many thanks
btw, thanks a million for kindly explaining those questions. much appreciated for helping with my understanding of this project.
Use the RPi_Cam_Web_Interface one. The other one (this) is effectively dead. It has been superceded by the first which is a total replacement for the original silvanmelchior one. It includes the main installer and all my changes.
My RPi_Cam_Web_Interface one will also be where I put some more enhancements I have in the works.
then, I am currenlty using the correct one. I gitted this one, https://github.com/roberttidey/RPi_Cam_Web_Interface
However, the I could not find schedule and other extra functions you mentioned. here's a screen capture. thanks
The main index.php was out of date and didn't have the schedule button.
It is updated now. You can just extract the index.php from the repository and sudo cp it into /var/www
did it now. thanks a lot.
HI robert,
when I click start on the "schedule page", then stop it at same page, the main page is still lingering on "time-lapse stop" or "motion detection stop". It seems doing either Time Lapse or Video capture until I hit stop on the main page. Hitting "stop" on scheduler doesn't do this effect. Or that "stop" on scheduler is just to stop a "scheduled" task, not stopping the current session?
Is this normal or could it be adjusted? thanks
Also, what are those "minutes" I am supposed to set up. Can you kindly provide a brief "how to"? thanks
HI Robert,
Is this the correct understanding of the flow? thanks in advance.
Work flow:
I. Based on the following setting in motion conf, motion anylyze each frame with this resultuion 352x288. This could be changed to match that's defined in step#2. width 352 height 288
II. The source of image is feeded by raspMJPEG via this in motion conf. netcam_url http://localhost/cam_pic.php
The size of this feed is defined in /etc/raspmjpeg. This size could be changed to get bigger or smaller feeds.
width 512 quality 25 divider 1
III. Based on the following setting in motion conf, motion conclude there's a motion. threshold 1500
IV. Based on the following setting in motion conf, motion save a jpeg file in defined directory.
output_normal first jpegfilename vthumb%Y%m%d_%H%M%S target_dir /var/www/media
V. At the same time of step #4, motion send instruction to raspMJPEG to capture video or time-lapse images at resolution defined in /etc/raspmjpeg. The captured video/image resolution could be changed here. (what are valid resolution for Pi Cam? and could it be changed in text file? it seems on GUI, those resolution pixels are greyed out and you can not do it there)
on_event_start echo '1' > /var/www/FIFO1 on_event_end echo '0' > /var/www/FIFO1
VI. If I don't want involve raspMJPEG, I could simply, VI.1 increse step #2's image size, for example, to 1280x1024 VI.2 then, just use saved vthumb file as the captured image VI.3 I could define "post capture" to do a more capture.
would this work? pros and cons?
On the schedule page the Start / Stop refers to the schedule process itself which is running in the background a bit like raspimjpeg. It does not have any direct effect on the running or not of any captures or time lapse. Normally it should just be left started. It is only necessary to stop it and restart it if you change the settings as it only picks them up during the start sequence. I may be able to automate that but haven't done it yet. So if you change the settings then you need to stop / start for them to take effect.
Workflow / motion settings.
I II Motion is continuously fetching new cam.jpg via that url. The size of the cam.jpg is actually set by raspimjpeg. It is defined in raspimjpeg settings (512). The height varies according to the aspect ratio selected by the main camera settings. When motion fetches via the url it actually just uses the actual width and height of what it gets. The motion height and width settings are ignored.
I do filter out a lot of motion settings and those could be added to the list as well but I was keeping basic stuff in to start with in case I change other things around.
III Yes
IV that setting in motion causes motion to store the first frame of a capture with that filename. The preview uses this as a thumbnail. Currently if you do manual image recordings or image captures then preview.php has to create thumbnails itself which slow down switching into this view. I am changing this so that raspimjpeg itself generates thumbnails which will simplify it a lot and avoid any delay waiting for thumbnails to be generated.
V You should be able to change the resolutions and frame rates via the camera settings part from the main page. You can either select one of the presets or enter your own custom settings. If you use the custom boxes then I suggest selecting one of the presets first and then changing the values to what you want.
VI I don't think that will work. You need to have raspimjpeg working here. But I am starting to work on raspimjpeg now. Up till now I have just made web page changes. By changing mjpeg I think I will be able to make it more flexible in the capture including pre motion capture and extended post motion capture.
HI Robert,
What a lovely explanation to the questions I have. Thanks a lot.
Another point is that we could leverage different threadx.conf under motion. Then, thread1.conf deals with Pi Cam specifically; and thread2.conf deals with an attached USB cam, same for thread3.conf with another usb cam. If this works, then, we can achieve similar result as MotionPie, function wise. That's how motionpie is using utilizing different threads for different cam. So, raspMJPEG is triggered by motione's thread1.conf and motion-mmal (or motion itself) is triggered by thread2.conf for usb cam.
You think this is doable? Many many thanks.
One more thing about setting custom values for raspMJPEG on GUI. It looks that I can put letters, numbers in front of existing value there; however, it's always greyed out and I can't delete or put numbers after. Not much I can do. Any reason this is happening?Even tried "seclect options" menu alone. We should have a "custom setting" from "select menue". thanks.
Not sure why you are having trouble with settings. This is original code which I haven't looked at as it works fine for me. I click on a preset and the custom boxes fill in with the preset values. I can then click in any of the boxes and delete and change the numbers. THis might be a browser related thing as these changes are being done in the browser and then the values are fed back when you click OK.
What browser are you using? My default is Chrome.
On the question of the minutes numbers in the schedule page. THey are there to define offsets from sunrise and sunset. These are calculated based on latitude an dlongitude and then the day is split into 4 periods Dawn begins DawnStart Minutes relative to sunrise so putting -60 in there makes Dawn start 1 hour before sunrise. Day begins DayStart Minutes relative to sunrise, so -10 makes the day start 10 minutes before sunrise or 30 makes it start 30 minutes after sunrise. Similarly for Day End relative to sunset when Dusk begins. Dusk lasts until Dusk End minutes relative to sunset. It becomes night and then the cycle starts all over again.
The table below then says what to do in each period. Modes determines what to do when each period starts; so different camera settings may be set like going into night exposure mode. The ON and OFF determine how to translate motion ON and Motion OFF in each period.
HI Robert,
Is this possible?
Another point is that we could leverage different threadx.conf under motion. Then, thread1.conf deals with Pi Cam specifically; and thread2.conf deals with an attached USB cam, same for thread3.conf with another usb cam. If this works, then, we can achieve similar result as MotionPie, function wise. That's how motionpie is using utilizing different threads for different cam. So, raspMJPEG is triggered by motione's thread1.conf and motion-mmal (or motion itself) is triggered by thread2.conf for usb cam.
You think this is doable? Many many thanks.
In principle it is doable, but it would need a lot of work at the Web end to integrate this together.
I am focussed at the moment on improvements to raspimjpeg and my cameras are all raspberry because I like the higher quality possible.
Another possibility is to integrate several independent raspimjpeg Raspberry cameras together so that they can be seen from one web interface.
I have cross linked the idea with MotionPies' ccrison. Hope there's some sort brainstorm going.
BTW, I am using firefox on linux. will check chrome out. tks
HI roberttidey,
I have not tried yours yet and will do it soon. I have got one spare pi with picam and have it installged with RPI CAM web interface on minibian distrobution. It works as intented. However, I am struggling with a motion detection system running up properly, with video or stills recorded. I have 4 other Pi's with pi cam + usb cam on MotionPie installed and works fine. But, it seems that I can not get better frame rate due to MotionPie ties on motion or motion-mmal in order to apply to both Pi Cam and USB cam.
https://github.com/ccrisan/motionPie/issues/124 I found the this motioneeye by ccrisan using very neat and light weight python webserver. It looks like that you are working on python as well.
I was wondering, whether you have some interest in forking/borrowring code from ccrisan's motioneye and get your version of RPI CAM WEB interface up with that, instead of apache, etc.
So , ideally, your version is using raspMJPEG, with motioneye, to have setting of raspMJPEG and Motion conf setting in GUI and have a preview window or a seperate stream one on 8081, etc.
In the future, if you and other experts, can work out a raspMJPEG or adapt it so that it also support usb web cam attached to it and have same bit rate effect, it would be great!
Just some thougts to share.
thanks