CharlyDelta
Posts: 122
Joined: Thu Jul 18, 2013 4:04 am
Location: Montreal

Re: RPi Cam Web Interface ... button to control a motor

Fri Jun 14, 2019 6:00 pm

CharlyDelta wrote:
Tue Jun 11, 2019 2:28 am
Hello...


I know how to add buttons and edit the userbuttons file. Now, by clicking on a button, I would like to operate a DC motor with an L293.

Don't mind about wiring. How do I configure those buttons to do this? A path to a solution would help me a lot.




Image

Found that on RPI CAM WEB page:
This is controlled by a userbuttons file in the main web install folder (e.g. /var/www/html). If the file does not exist then the page displays without any extra buttons. If the file does exist then it can contain the definitions for up to 6 user buttons,

The file is just a text file and contains definition lines which are just

buttonName,macroname.sh
When a button is pressed then the corresponding macro is executed.

Does that mean that you can't execute a Python file by clicking a button?

Tnx for any informations.

CharlyDelta
Posts: 122
Joined: Thu Jul 18, 2013 4:04 am
Location: Montreal

Re: RPi Cam Web Interface ... button to control a motor

Fri Jun 14, 2019 6:28 pm

CharlyDelta wrote:
Tue Jun 11, 2019 2:28 am
Hello...


I know how to add buttons and edit the userbuttons file. Now, by clicking on a button, I would like to operate a DC motor with an L293.

Don't mind about wiring. How do I configure those buttons to do this? A path to a solution would help me a lot.




Image

Partially resolved

created in macro an open.sh file,

#!/bin/sh
python open.py

but it doesn't start, a permission problem.

ras07
Posts: 60
Joined: Tue May 22, 2018 4:04 am

Re: RPi Cam Web Interface ... button to control a motor

Fri Jun 14, 2019 7:18 pm

CharlyDelta wrote:
Fri Jun 14, 2019 6:28 pm
CharlyDelta wrote:
Tue Jun 11, 2019 2:28 am
Hello...


I know how to add buttons and edit the userbuttons file. Now, by clicking on a button, I would like to operate a DC motor with an L293.

Don't mind about wiring. How do I configure those buttons to do this? A path to a solution would help me a lot.


Partially resolved

created in macro an open.sh file,

#!/bin/sh
python open.py

but it doesn't start, a permission problem.
Scripts run as the www-data user. If you switch to that user by executing

Code: Select all

sudo su www-data
and run your scripts from there, you should be able to diagnose permission problems. If your scripts successfully execute from that user, they should work in the UI when you press that button.

CharlyDelta
Posts: 122
Joined: Thu Jul 18, 2013 4:04 am
Location: Montreal

Re: RPi Cam Web Interface

Sat Jun 15, 2019 2:54 pm

Ok... now I can get motor working good,

Now I want to get temperature and humidity (from DHT22) printed in the camera page web beside the date and the hour.

How can I do this ??

Thank you for your help.

zoktar
Posts: 1
Joined: Mon Jan 07, 2013 3:33 am

Re: RPi Cam Web Interface

Sat Jun 15, 2019 2:57 pm

tk1 wrote:
Mon Mar 11, 2019 12:24 am
For the last few weeks (in my spare time), I've been trying to figure out how to get a video file from the time-lapse images. I finally figured it out (for me, the option to do it from within the otherwise excellent picam software wouldn't work).

Anyone wanting to convert the time-lapse images to an mp4, try this:

Remote to your Pi (either SSH or VNC and open a terminal), then enter this command:

Code: Select all

/usr/bin/ffmpeg -f image2 -framerate 10 -i "/var/www/html/media/tl_0000_%04d*.jpg" -r 30 -pix_fmt yuv444p -vcodec mpeg4 Documents/timelapse.mp4
Where:
-f = force format, 'image2'
-framerate = input frame rate (per second)
-i = input file(s)
%04d = 4 decimal characters (e.g. 0001) NOTE: input file must be in double quotes
-r = output frame rate (per second)
-pix_fmt = output format
-vcodec = output codec

This will create a file, timelapse.mp4, in your Documents folder.

Hope this helps and saves people the time/effort it took me to work this out.

-tk1


pi@camera:~ $ /usr/bin/ffmpeg -f image2 -framerate 10 -i "/var/www/html/media/tl_0000_%04d*.jpg" -r 30 -pix_fmt yuv444p -vcodec mpeg4 file.mp4
ffmpeg version 3.2.14-1~deb9u1+rpt1 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 6.3.0 (Raspbian 6.3.0-18+rpi1+deb9u1) 20170516
configuration: --prefix=/usr --extra-version='1~deb9u1+rpt1' --toolchain=hardened --libdir=/usr/lib/arm-linux-gnueabihf --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-omx-rpi --enable-mmal --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --arch=armhf --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 34.101 / 55. 34.101
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.101 / 57. 56.101
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
[image2 @ 0x1c83620] Could find no file with path '/var/www/html/media/tl_0000_%04d*.jpg' and index in the range 0-4
/var/www/html/media/tl_0000_%04d*.jpg: No such file or directory


cant figure out the input error

ras07
Posts: 60
Joined: Tue May 22, 2018 4:04 am

Re: RPi Cam Web Interface

Sun Jun 16, 2019 1:28 am

CharlyDelta wrote:
Sat Jun 15, 2019 2:54 pm
Now I want to get temperature and humidity (from DHT22) printed in the camera page web beside the date and the hour.

How can I do this ??
Easiest way to do this is to periodically write out the temperature and humidity to /dev/shm/mjpeg/user_annotate.txt, and then use the %a parameter in the annotation field to add the contents of this file to the annotation.

CharlyDelta
Posts: 122
Joined: Thu Jul 18, 2013 4:04 am
Location: Montreal

Re: RPi Cam Web Interface

Mon Jun 17, 2019 12:21 pm

ras07 wrote:
CharlyDelta wrote:
Sat Jun 15, 2019 2:54 pm
Now I want to get temperature and humidity (from DHT22) printed in the camera page web beside the date and the hour.

How can I do this ??
Easiest way to do this is to periodically write out the temperature and humidity to /dev/shm/mjpeg/user_annotate.txt, and then use the %a parameter in the annotation field to add the contents of this file to the annotation.
Thank you ras07... success !!

jenjimah
Posts: 1
Joined: Thu Jun 20, 2019 7:19 pm

Re: RPi Cam Web Interface

Thu Jun 20, 2019 7:42 pm

I have a question about using the RPi Cam Web Interface for data collection purposes (specifically for making a spectrometer or conducting NDVI calculations pixel-by-pixel), where it's important to have non-lossy data format and manual camera control.

Three main features interest me that I wasn't able to access with the web interface:
- ability to capture in .png format
- ability to capture in YUV or raw RGB format (this would be even better than .png)
- ability to do longer exposures (up to the 6s or 10s max exposure time for pi cameras V1 and V2, respectively)

I wanted to check if it was an easy tweak to get these options before deciding if I had to take an alternative route altogether.
Regarding exposure time, I was able to set it higher than the specified limit of "330000" using the shutter speed option, (e.g. pictures with "600000" shutter speed were brighter than "330000", and the EXIF data confirms the exposure was "0.6 s", but I wasn't able to get exposure to be over 1s long.

ras07
Posts: 60
Joined: Tue May 22, 2018 4:04 am

Re: RPi Cam Web Interface

Fri Jun 21, 2019 3:09 am

jenjimah wrote:
Thu Jun 20, 2019 7:42 pm
I have a question about using the RPi Cam Web Interface for data collection purposes (specifically for making a spectrometer or conducting NDVI calculations pixel-by-pixel), where it's important to have non-lossy data format and manual camera control.
Sounds like a cool project! But I don't think this is the right software for that application. The MJPEG format is inherently lossy, and RPi-CWI doesn't directly deal with the low-level camera control (it hands off to the raspimjpeg package for that). To badly oversimplify, you can think of raspimjpeg as just taking JPG images as fast as it can; then RPi-CWI can turn that into video, time-lapse, or whatever. But lossless formats and manual control aren't among its design points. Unless you can refactor your solution around those constraints (perhaps there's something to be gained from rapid image capture, even if fidelity suffers), I think you may need to look elsewhere.

I'm sure there is applicable software out there, but I'm not familiar with it - perhaps others will chime in. I'd be interested in hearing about the solution you settle on; I hope you'll report back. Good luck!

itsmedoofer
Posts: 359
Joined: Wed Sep 25, 2013 8:43 am

Re: RPi Cam Web Interface

Tue Jun 25, 2019 7:24 pm

HI,

Just a heads up the installer does not work with the new "Buster" images, missing packages..

Edit:-

It should be fairly easy to update the dependencies php7.0 needs to be replaced with php7.3 and libav-tools with ffmpeg.

However I'm not sure how much of an impact the switch to ffmpeg will make, will "avconv" have to be replaced with "ffmpeg", when it went the other way the syntax stayed the same so we could be lucky and just have to a find-replace...

I

User avatar
Mettauk
Posts: 237
Joined: Mon Dec 10, 2012 12:40 pm
Location: Zarg

Re: RPi Cam Web Interface

Fri Jun 28, 2019 12:01 am

itsmedoofer wrote:
Tue Jun 25, 2019 7:24 pm
HI,

Just a heads up the installer does not work with the new "Buster" images, missing packages..
...
No worries, by the time RPi Cam is updated the Raspberry Pi 4k camera module will be out, with IR cut version, zoom lens and af!
As humans we have been the same for a very very long time, technology changes how we do... not who we are as people.

QuarkMan
Posts: 5
Joined: Wed May 25, 2016 12:10 pm

Re: RPi Cam Web Interface

Mon Jul 01, 2019 10:27 am

Any timeline as to when the installation script will be updated to take into account the new Buster build?
-------------------------------
Adrian
Pi Zero and 2x Pi3b

Manisch
Posts: 4
Joined: Sun May 12, 2019 1:34 pm

Re: RPi Cam Web Interface

Tue Jul 02, 2019 8:53 am

I'm still having the issue that the Camera is rebooting quite often. I would say...once every 10 minutes? Sometimes more, sometimes less...

dansinclair25
Posts: 1
Joined: Wed Jan 14, 2015 11:41 am

Re: RPi Cam Web Interface

Tue Jul 02, 2019 9:05 am

Not sure if this has already been asked so I apologise in advance.

I'm looking at adding dynamic text to the images/"stream". The text would come from a text file that's constantly being written to by a python script running elsewhere on the Pi and can update at any point. How would I go about implementing this?

User avatar
Mettauk
Posts: 237
Joined: Mon Dec 10, 2012 12:40 pm
Location: Zarg

Re: RPi Cam Web Interface

Tue Jul 02, 2019 1:14 pm

Write your (short) text to /dev/shm/mjpeg/user_annotate.txt, and then use the %a parameter in the annotation field to add the contents of this file to the annotation.
As humans we have been the same for a very very long time, technology changes how we do... not who we are as people.

User avatar
Mettauk
Posts: 237
Joined: Mon Dec 10, 2012 12:40 pm
Location: Zarg

Re: RPi Cam Web Interface

Wed Jul 03, 2019 3:04 pm

Possible link to Buster issues??

Hmm, I'm running Stretch and just tried to run <i>./update.sh</i> and got

Code: Select all

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package php7
E: Unable to locate package php7-cli
E: Unable to locate package libapache2-mod-php7
I was trying to update v6.5.1, I got the Nothing to update message then the above? All seems to be working but that matches the message when trying to install on a Pi4b

EDIT: Ah, now installs fine on Buster but will not now install on Jessie!
Last edited by Mettauk on Wed Jul 03, 2019 11:13 pm, edited 1 time in total.
As humans we have been the same for a very very long time, technology changes how we do... not who we are as people.

User avatar
Mettauk
Posts: 237
Joined: Mon Dec 10, 2012 12:40 pm
Location: Zarg

Re: RPi Cam Web Interface

Wed Jul 03, 2019 11:12 pm

QuarkMan wrote:
Mon Jul 01, 2019 10:27 am
Any timeline as to when the installation script will be updated to take into account the new Buster build?
Just installed RPi Cam on Buster, no problems, weirdly it will not now install on Jessie!!!
As humans we have been the same for a very very long time, technology changes how we do... not who we are as people.

itsmedoofer
Posts: 359
Joined: Wed Sep 25, 2013 8:43 am

Re: RPi Cam Web Interface

Thu Jul 04, 2019 11:39 am

Mettauk wrote:
QuarkMan wrote:
Mon Jul 01, 2019 10:27 am
Any timeline as to when the installation script will be updated to take into account the new Buster build?
Just installed RPi Cam on Buster, no problems, weirdly it will not now install on Jessie!!!
The script now calls for php7.3 to be installed this is not available on earlier versions, if you look on the git page you can see what has changed and undo the changes to get it to work, there are only a couple of lines... Dont update though or it could break..

My advice would be to start again with Buster..

Maddust
Posts: 1
Joined: Thu Jul 04, 2019 6:01 pm

VEYE-MIPI-290 Camera

Thu Jul 04, 2019 6:16 pm

researching for better camera options for the raspberry pi i found this camera http://www.inno-maker.com/product/mipi-cam-290/. which has great low light performance for the case im looking to use the interface

for my understanding Raspi Web cam interface does not work with usb cameras but i was wondering since this camera works on I2c and regular ribbon connection if there any way to modify the code to make it work. I'm mainly interest in the schedule capabilities and video recordings to use this camera with the interface.

more info here:
http://www.inno-maker.com/wp-content/up ... v1.0-2.pdf

http://www.inno-maker.com/wp-content/up ... v1.0-2.pdf

ill appreciate any help

thanks

btidey
Posts: 1622
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Fri Jul 05, 2019 6:42 pm

itsmedoofer wrote:
Thu Jul 04, 2019 11:39 am
Mettauk wrote:
QuarkMan wrote:
Mon Jul 01, 2019 10:27 am
Any timeline as to when the installation script will be updated to take into account the new Buster build?
Just installed RPi Cam on Buster, no problems, weirdly it will not now install on Jessie!!!
The script now calls for php7.3 to be installed this is not available on earlier versions, if you look on the git page you can see what has changed and undo the changes to get it to work, there are only a couple of lines... Dont update though or it could break..

My advice would be to start again with Buster..
Buster would be best choice.

You should be able to change the php version to 7.1 at start of install for earlier versions.

CharlyDelta
Posts: 122
Joined: Thu Jul 18, 2013 4:04 am
Location: Montreal

Re: RPi Cam Web Interface annotate

Sat Jul 06, 2019 3:14 am

Code: Select all

 time import sleep

import Adafruit_DHT

DHT_SENSOR = Adafruit_DHT.DHT22
DHT_PIN = 4

while True:
    humidity, temperature = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)

    if humidity is not None and temperature is not None:
        print("Temp={0:0.1f}*C  Humidity={1:0.1f}%".format(temperature, humidity))
    else:
        print("Failed to retrieve data from humidity sensor")
    annotate = open("/dev/shm/mjpeg/user_annotate.txt", 'w')
    annotate.write('Temp={0:0.1f}*C  Humidity={1:0.1f}%'.format(temperature, humidity))
    annotate.close()
    sleep (10)
In the first code above, everything is fine... the annotation is inscribed in the camera window.

In the two codes below, it doesn't work. I tried about ten different codes for the 18b20, without success.

However, the temperature is displayed on the terminal window.

Why does it work with a code for DHT22 and not for an 18b20?


any idea will be useful to me because right now, I'm stuck


Code: Select all

import time

try:
        while True:
                tempfile = open("/sys/bus/w1/devices/28-0516b4b4a0ff/w1_slave")
                thetext = tempfile.read()
                tempfile.close()
                tempdata = thetext.split("\n")[1].split(" ")[9]
                temperature = float(tempdata[2:])
                temperature = temperature / 1000
                print temperature

                annotate = open("/dev/shm/mjpeg/user_annotate.txt", 'w')
                annotate.write('temperature')
                annotate.close()

                time.sleep(1)
except KeyboardInterrupt:
        pass

Code: Select all

#!/usr/bin/env python

import time

DS18B20="/sys/bus/w1/devices/28-0516b4b4a0ff/w1_slave"

r = 0

while True:

   r += 1

   f = open(DS18B20, "r")
   data = f.read()
   f.close()

   (discard, sep, reading) = data.partition(' t=')

   t = float(reading) / 1000.0

   print("{} {:.1f}".format(r, t))

annotate = open("/dev/shm/mjpeg/user_annotate.txt", 'w')
annotate.write('{} {:.1f}".format(r, t))')
annotate.close()
time.sleep (3)

CharlyDelta
Posts: 122
Joined: Thu Jul 18, 2013 4:04 am
Location: Montreal

Re: RPi Cam Web Interface ANNOTATE (2)

Sat Jul 06, 2019 10:06 pm

With the code below, (read_temp() is printed on the video image, instead of the temperature.

But in terminal screen, the temperature is showing normally.

I've tried almost everything with the combinations. I need some research ideas.

Code: Select all

import os
import glob
import time

os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')

base_dir = '/sys/bus/w1/devices/'
device_folder = glob.glob(base_dir + '28*')[0]
device_file = device_folder + '/w1_slave'

def read_temp_raw():
    f = open(device_file, 'r')
    lines = f.readlines()
    f.close()
    return lines

def read_temp():
    lines = read_temp_raw()
    while lines[0].strip()[-3:] != 'YES':
        time.sleep(0.2)
        lines = read_temp_raw()
    equals_pos = lines[1].find('t=')
    if equals_pos != -1:
        temp_string = lines[1][equals_pos+2:]
        temp_c = float(temp_string) / 1000.0
        temp_f = temp_c * 9.0 / 5.0 + 32.0
        return temp_c
while True:
        print(read_temp())
        annotate = open("/dev/shm/mjpeg/user_annotate.txt", 'w')
        annotate.write('(read_temp()')
        annotate.close()
        time.sleep(1)

wpballa1
Posts: 59
Joined: Sat Jun 27, 2015 12:49 am

Re: RPi Cam Web Interface

Sun Jul 07, 2019 12:37 am

Bob,
Now that Buster is out I'm having problems updating a Stretch installation. update.sh seems to work fine, but after I accept all the settings I get the following messages
E: Unable to locate package php7
E: Unable to locate package php7-cli
E: Unable to locate package libapache2-mod-php7
And the update to 6.5.1 process dies. I must reboot to get the camera going again, working through the interface it won't let me restart things. All of this is after a update/upgrade within Stretch. I can't tell whose problem this is.
Bill

Let me be a bit more clear. I have no intention of upgrading these Raspberry Pis to Buster as they are 3000 miles away and I can't easily get my hands on them. So, I guess I will leave the one at 6.4.50, but is there a way I could revert the 6.5.1 back to 6.4.50?

Manisch
Posts: 4
Joined: Sun May 12, 2019 1:34 pm

Re: RPi Cam Web Interface

Mon Jul 08, 2019 11:54 am

Manisch wrote:
Tue Jul 02, 2019 8:53 am
I'm still having the issue that the Camera is rebooting quite often. I would say...once every 10 minutes? Sometimes more, sometimes less...
Isn't there anyone who could help? :(

I don't want to sell this stuff again, because my project doesn't work...

ras07
Posts: 60
Joined: Tue May 22, 2018 4:04 am

Re: RPi Cam Web Interface

Mon Jul 08, 2019 3:05 pm

Manisch wrote:
Mon Jul 08, 2019 11:54 am
Manisch wrote:
Tue Jul 02, 2019 8:53 am
I'm still having the issue that the Camera is rebooting quite often. I would say...once every 10 minutes? Sometimes more, sometimes less...
Isn't there anyone who could help? :(

I don't want to sell this stuff again, because my project doesn't work...
Can you give some more information? What do you mean exactly by "the camera is rebooting" - the Pi itself reboots? What Pi version, OS version, etc.

Return to “Camera board”