RPI3 Camery + Pimioroni (Adafruit) Pan/tilt + RPi-Cam-Web-Interfac

3.11.2016
Hello,

I want to use the RPi-Cam-Web-Interface to control/view via a wlan connection.
RPi-Cam-Web-Interface show the mindsensors.com servoblaster version and I would like to use the Pmoroni/Adafruit Servo sontroller, when that is running a new project with a stronger PWM Pan/tilt Hardware to mount the camera,Ultasonic distance,IR and other sensors

Question: How does one integrate adafruit pwm controller(s) in the .RPi-Cam-Web-Interface.?
Do you have a more powerful Pan/tilt?

Many thanks

Our PanTiltHAT is on the way, but I don’t think the Pan/Tilt assembly is any more powerful- they probably use the same hobby servos.

As for integrating into RPi-Cam-Web-Interface, it looks like you’d need to start here: https://github.com/silvanmelchior/RPi_Cam_Web_Interface/blob/master/www/pipan.php

Normally I’d say try politely raising an Issue to ask for compatibility, but the project looks a little dead :(

1 Like

Thanks for the fast reply.

For the first project you Pan/tilr will be OK.
BUT I want to replace the servoblaster lib. with the adafruit lib.
and it is this aspect I am unsure about. the Rpi-web-cam only deals with
the version.
You mention that the SW may be dying - is there an alternative I am missing?
If the RPI is here to stay, when I get time, I’ll try to integrate the
adafruit or any
pan/tilt to the system - again when I get time!

Two more questions:

  1. Have you a case+HW for a large (7" Plus) screen?
  2. Got a decent RPi Camera case?
    All the best

Nigel Trewartha

I’ve seen several people on Twitter making interfaces for PanTilt HAT which might be a better choice. It’s not a difficult thing to accomplish in Python and Flask and is perhaps an example I should put together.

The video feed is a little trickier, though :D

  1. You could use: https://shop.pimoroni.com/products/smartipi-touch or https://shop.pimoroni.com/products/raspberry-pi-7-touchscreen-display-with-frame - both with the official 7" touch screen which I use on a daily basis.

  2. The SmartiPi case includes a camera case :D

I have been looking at this arena easiest way to get a quick look ay what you can do is download PiVision.

That article gives a rundown but its so easy just to pipe the camera through netcat.

You can do it from the command line.

raspivid -p 0,0,640,480 -t 5000 -o – | nc [0] 5001 -w 640 -h 480 -fps 30 -b 1777778 -v -br 50 -co 0 -sh 0 -sa 0 -awb auto -ev 5 -ex auto -rot 0 -mm average

The Python lib picamera is excellent and its more of what you can not do than what you can do as you will have to take a look.

https://picamera.readthedocs.io/en/release-1.12/

The camera in the link is like $150 !!! its $30 for a v2.1 cam and a Pi Zero and depending on how you connect wifi / ethernet its a dongle or go usb and set the zero up a an ethernet gadget
2x Pi Zero could so all the preprocessing and stream to a Pi3 and get power and ethernet over usb.

Not sure why you want a stronger pan/tilt mech (big lens?) all the main stream pan tilt mechs I have seen as still direct drive and its the servo.
I think you can swap out the towerpro SG 90 for MG 90 which have metal gears.

Also the openCV stuff has examples for streaming.

I’ve just written a very crude Python Flask web app which will let you control PanTilt HAT from your browser: https://github.com/pimoroni/pantilt-hat/tree/pixel-types/examples/pantiltweb

It’s possible to stream to the web, too, which can then just be included in a good old iFrame. I can’t remember how I did that though and I don’t have a Pi Camera at home!

Phil your prob the best one to ask but the Remote GPIO I am struggling to get any info on it, do you know of the documentation?

I am presuming you could even redirect i2c over tcp via Remote GPIO but haven’t found enough info.
I will have to take a look at pantiltweb :)

Is this GPIO Zero’s remote GPIO features? I’ve honestly never tried it, or even looked at it! Might be worthy of another forum thread, though, since some other folks around here might be more familiar with it than me.

Its part of the desktop raspi-config remote gpio enable on boot or not, part from that I really don’t know and have been trying to find out.
Its not in the command line one but starts a daemon that apparently can be accessed remotely… ?

10.12.2016

Thank you all for your suggestions.
But at he moment I am interested primarily in the linux web-cam software since it is
in use on another web cam project.So I would like to maintain compatibility.
I need to control the Camera Pan/Tilt while viewing, and the web-cam SW does that
quite well.
I will need to learn PHP and More HTML then can change the SW myself.
I could then post the changes to pimoroni and raspberrypi.org

BUT , at a first glance , that PiVision looks interest and I’ll certainly try it out, I didn’t find
and hooks for Pan/tilt control.

Thanks again and I really like the PanTilt Hat…well done!

BD

Often cctv is pelcoD format https://www.commfront.com/pages/pelco-d-protocol-tutorial

http://bruxy.regnet.cz/web/programming/EN/rs485-raspberry-pi/

If you are using zoneminder this might already be done for you and all you need to do is the pan / tilt link

http://www.holylinux.net/content/raspberry-pi-webcam-zoneminder

If it is zoneminder then its prob yes

https://pypi.python.org/pypi/PiPan

http://zoneminder.readthedocs.io/en/stable/userguide/cameracontrol.html

Zoneminder is very hard to install. I tried it and unfortunately did not run under Raspian PIXEL.

It isn’t too hard to use the Pimoroni Pan/Tilt Python library with the RPi-Cam.

Install the Pimoroni Pan/Tilt library per the instructions here (and test basic operation using one of the examples): https://github.com/pimoroni/pantilt-hat

Follow the RPi-Cam instructions for the mindsensors setup per the link below with the following changes:
http://elinux.org/RPi-Cam-Web-Interface#Pan-Tilt_or_Pi-Light

  1. Change the contents of the pipan_pipe.py to the code at the bottom of the post which will act as a shim and allow the Pan/Tilt library to act like the mindsensors interface with the same pipe (this isn’t the best solution but at least it won’t be overwritten when the RPi-Cam software is updated). Please note - I am not a Python programmer, feel free so suggest improvements.

  2. Save the pipan_pipe.py somewhere sensible (e.g. /home/pi/Pimoroni) and run it to make sure it has no errors (python pipan_pipe.py, ^c to stop)

  3. When editing /etc/rc.local use the path above (e.g. python /home/pi/Pimoroni/pipan_pipe.py &)

If all other instructions are followed it should just work… I don’t have a light on mine so haven’t tried to get that working, if I get one I will update the post

#!/usr/bin/env python
 
import time
import os, sys
import pantilthat
 
MIN_PIPAN_PAN = 50
MAX_PIPAN_PAN = 250
MIN_PIPAN_TILT = 80
MAX_PIPAN_TILT = 220

MIN_PANTILT_PAN = -90
MAX_PANTILT_PAN = 90
MIN_PANTILT_TILT = -86
MAX_PANTILT_TILT = 90

# Number to add to the given pan or tilt input
pan_corr  = ((MAX_PANTILT_PAN  + MIN_PANTILT_PAN)  - (MAX_PIPAN_PAN  + MIN_PIPAN_PAN))/2.0
tilt_corr = ((MAX_PANTILT_TILT + MIN_PANTILT_TILT) - (MAX_PIPAN_TILT + MIN_PIPAN_TILT))/2.0

# Scaling factor to apply after correction (force floating point division)
pan_scale  = 1.0 * (MAX_PANTILT_PAN  - MIN_PANTILT_PAN)  / (MAX_PIPAN_PAN  - MIN_PIPAN_PAN)
tilt_scale = 1.0 * (MAX_PANTILT_TILT - MIN_PANTILT_TILT) / (MAX_PIPAN_TILT - MIN_PIPAN_TILT)
   
while True:
  pipein = open("/var/www/html/FIFO_pipan", 'r')
  line = pipein.readline()
  line_array = line.split(' ')
  if line_array[0] == "servo":
    # Pantilt expects an int, int is also used for string to int conversions of the parameters
    pantilthat.pan( int((int(line_array[1]) + pan_corr)  * pan_scale))
    pantilthat.tilt(int((int(line_array[2]) + tilt_corr) * tilt_scale))
  #elif line_array[0] == "led":
    # p_led.createPiLight(int(line_array[1]),int(line_array[2]),int(line_array[3]))
  pipein.close()

24.4.2017

Hello ,

I was working on this but this solution is more elegant than mine.

I wanted to call the Pan/Tilt programmes directly from the php, thus
removing the pipe.
which would mean a fair amount of changes - not nice and error prone.

Well done indeed

Nigel

Thanks, not sure I would call it elegant though…

I have ordered a neopixel light so hopefully can update the code to include that next week. Let me know if you get this working - there are a few others looking for a solution and I didn’t want to post links to this until I had confirmation that it worked for someone else.

Cheers

Hello,

Thanks again for this bash!

Is there an update to this ?

I have so much to do I can only really get started on improving elinux +
mindsensor software

Thanks again!

Piimoroni sells some really suberb hardware ! Well done!

Nigel Trewartha