pageauc / speed-camera

A Unix, Windows, Raspberry Pi Object Speed Camera using python, opencv, video streaming, motion tracking. Includes a Standalone Web Server Interface, Image Search using opencv template match and a whiptail Admin Menu Interface Includes picam and webcam Plugins for motion track security camera configuration including rclone sync script. watch-app allows remotely controller camera configuration from a remote storage service name. Uses sqlite3 and gnuplot for reporting. Recently added openalpr license plate reader support.
Apache License 2.0
967 stars 170 forks source link

Weird cam behaviour #118

Closed will-code-for-pizza closed 10 months ago

will-code-for-pizza commented 2 years ago

Hi Claude, sorry to disturb you again, but probably you have faced this issue in the past...

If I use my PiCam 1.3 with a simple Python script, which generates a small website with live video stream in it, all is working fine...

Using 'speed-cam.py' results in

$ ./speed-cam.py 
----------------------------------------------------------------------
speed-cam.py 11.23  written by Claude Pageau
Motion Track Largest Moving Object and Calculate Speed per Calibration.
----------------------------------------------------------------------
Loading  Wait ...
2022-06-21 09:16:52 ERROR    <module>   Pi Camera Module Not Found supported=1 detected=1, libcamera interfaces=0
2022-06-21 09:16:52 ERROR    <module>   if supported=0 Enable Camera per command sudo raspi-config
2022-06-21 09:16:52 ERROR    <module>   if detected=0 Check Pi Camera Module is Installed Correctly
2022-06-21 09:16:52 ERROR    <module>   speed-cam.py 11.23 Exiting Due to Error

What confuses me ist the part 'supported=1 detected=1, libcamera interfaces=0'

The last option must be new, cause I could not find anything related.

Using Raspberry Pi OS 32 Bit Buster```

$ uname -a Linux speedcam 5.15.48-v7+ #1563 SMP Fri Jun 17 19:07:53 BST 2022 armv7l GNU/Linux


and newest speed-cam version.

Regards. Will.
pageauc commented 2 years ago

I just did an update and upgrade on my RPI running Buster. speed-cam.py detects the rpi camera module using the following command with my output below. Your vcgencmd is different and has ibcamera interfaces=0

vcgencmd get_camera
supported=1 detected=1

program simply looks for a zero in the command line and it appears on the version of Buster you have is different than mine

uname -a
Linux rpi-vid1 5.10.103-v7+ #1529 SMP Tue Mar 8 12:21:37 GMT 2022

armv7l GNU/Linux

I have made changes to the code to check specifically for supported and detected. This is another example of unix code changes that break things.

Do an UPGRADE from menubox.sh and retry new version. It will check for Bullseye or greater and also check Camera supported and detected parameters

I have done some quick testing. Please let me know your results Thanks Claude ...

On Tue, Jun 21, 2022 at 3:22 AM Will Code @.***> wrote:

Hi Claude, sorry to disturb you again, but probably you have faced this issue in the past...

If I use my PiCam 1.3 with a simple Python script, which generates a small website with live video stream in it, all is working fine...

Using 'speed-cam.py' results in

$ ./speed-cam.py

speed-cam.py 11.23 written by Claude Pageau Motion Track Largest Moving Object and Calculate Speed per Calibration.

Loading Wait ... 2022-06-21 09:16:52 ERROR Pi Camera Module Not Found supported=1 detected=1, libcamera interfaces=0 2022-06-21 09:16:52 ERROR if supported=0 Enable Camera per command sudo raspi-config 2022-06-21 09:16:52 ERROR if detected=0 Check Pi Camera Module is Installed Correctly 2022-06-21 09:16:52 ERROR speed-cam.py 11.23 Exiting Due to Error

What confuses me ist the part 'supported=1 detected=1, libcamera interfaces=0'

The last option must be new, cause I could not find anything related.

Using Raspberry Pi OS 32 Bit Buster```

$ uname -a Linux speedcam 5.15.48-v7+ #1563 SMP Fri Jun 17 19:07:53 BST 2022 armv7l GNU/Linux

and newest speed-cam version.

Regards. Will.

— Reply to this email directly, view it on GitHub https://github.com/pageauc/speed-camera/issues/118, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNPKZCJYFJTTQQYVEUUKTDVQFUSJANCNFSM5ZLIVQFA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- YouTube Channel at https://www.youtube.com/user/pageaucp http://www.youtube.com/user/pageaucp GitHub Repository at https://github.com/pageauc

pageauc commented 2 years ago

Will

I have installed a FRESH copy of Buster Legacy using rpi-imager on windows to burn a fresh sd distro. After all the apt updates and upgrades and speed camera curl install, everything worked well and I could not duplicate your output for vcgencmd get_camera that shows ibcamera interfaces=0

I suspect you are running Bullseye not the Buster Legacy. If that is the case speed camera should give you an error message saying Bullseye or greater is not supported and reburn a new Buster Legacy or earlier distro image.

Let me know how you are doing.

I may take a look at running speed-cam.py on Bullseye Claude ..

On Tue, Jun 21, 2022 at 8:34 AM Claude Pageau @.***> wrote:

I just did an update and upgrade on my RPI running Buster. speed-cam.py detects the rpi camera module using the following command with my output below. Your vcgencmd is different and has ibcamera interfaces=0

vcgencmd get_camera
supported=1 detected=1

program simply looks for a zero in the command line and it appears on the version of Buster you have is different than mine

uname -a
Linux rpi-vid1 5.10.103-v7+ #1529 SMP Tue Mar 8 12:21:37 GMT 2022

armv7l GNU/Linux

I have made changes to the code to check specifically for supported and detected. This is another example of unix code changes that break things.

Do an UPGRADE from menubox.sh and retry new version. It will check for Bullseye or greater and also check Camera supported and detected parameters

I have done some quick testing. Please let me know your results Thanks Claude ...

On Tue, Jun 21, 2022 at 3:22 AM Will Code @.***> wrote:

Hi Claude, sorry to disturb you again, but probably you have faced this issue in the past...

If I use my PiCam 1.3 with a simple Python script, which generates a small website with live video stream in it, all is working fine...

Using 'speed-cam.py' results in

$ ./speed-cam.py

speed-cam.py 11.23 written by Claude Pageau Motion Track Largest Moving Object and Calculate Speed per Calibration.

Loading Wait ... 2022-06-21 09:16:52 ERROR Pi Camera Module Not Found supported=1 detected=1, libcamera interfaces=0 2022-06-21 09:16:52 ERROR if supported=0 Enable Camera per command sudo raspi-config 2022-06-21 09:16:52 ERROR if detected=0 Check Pi Camera Module is Installed Correctly 2022-06-21 09:16:52 ERROR speed-cam.py 11.23 Exiting Due to Error

What confuses me ist the part 'supported=1 detected=1, libcamera interfaces=0'

The last option must be new, cause I could not find anything related.

Using Raspberry Pi OS 32 Bit Buster```

$ uname -a Linux speedcam 5.15.48-v7+ #1563 SMP Fri Jun 17 19:07:53 BST 2022 armv7l GNU/Linux

and newest speed-cam version.

Regards. Will.

— Reply to this email directly, view it on GitHub https://github.com/pageauc/speed-camera/issues/118, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNPKZCJYFJTTQQYVEUUKTDVQFUSJANCNFSM5ZLIVQFA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- YouTube Channel at https://www.youtube.com/user/pageaucp http://www.youtube.com/user/pageaucp GitHub Repository at https://github.com/pageauc

-- YouTube Channel at https://www.youtube.com/user/pageaucp http://www.youtube.com/user/pageaucp GitHub Repository at https://github.com/pageauc

pageauc commented 2 years ago

Hi Will

I finally Burned a raspberry pi os Bullseye distro using the Raspberry Pi Imager program. Performed setup for Raspberry Pi settings per prompts eg keyboard, datetime, password Etc. Ran sudo apt update and sudo apt upgrade Then ran sudo raspi-config Interface Options, Legacy Camera, Enabled rebooted to activate changes. opened ssh session and did speed camera curl install from github page (see instructions) This ran without issues. Note there are some messages about some packages but this is normal since it is designed for backward compatibility.

Changed to speed-camera folder and ran speed-cam.py without issue.

So to make a long story short, speed camera does run under Bullseye on the latest Bullseye distro with Legacy Camera enabled in raspi-config

I did have to make a change in the speed-cam.py code to accommodate different output from the vcgencmd get_camera command to check the camera.

On Tue, Jun 21, 2022 at 11:44 AM Claude Pageau @.***> wrote:

Will

I have installed a FRESH copy of Buster Legacy using rpi-imager on windows to burn a fresh sd distro. After all the apt updates and upgrades and speed camera curl install, everything worked well and I could not duplicate your output for vcgencmd get_camera that shows ibcamera interfaces=0

I suspect you are running Bullseye not the Buster Legacy. If that is the case speed camera should give you an error message saying Bullseye or greater is not supported and reburn a new Buster Legacy or earlier distro image.

Let me know how you are doing.

I may take a look at running speed-cam.py on Bullseye Claude ..

On Tue, Jun 21, 2022 at 8:34 AM Claude Pageau @.***> wrote:

I just did an update and upgrade on my RPI running Buster. speed-cam.py detects the rpi camera module using the following command with my output below. Your vcgencmd is different and has ibcamera interfaces=0

vcgencmd get_camera
supported=1 detected=1

program simply looks for a zero in the command line and it appears on the version of Buster you have is different than mine

uname -a
Linux rpi-vid1 5.10.103-v7+ #1529 SMP Tue Mar 8 12:21:37 GMT 2022

armv7l GNU/Linux

I have made changes to the code to check specifically for supported and detected. This is another example of unix code changes that break things.

Do an UPGRADE from menubox.sh and retry new version. It will check for Bullseye or greater and also check Camera supported and detected parameters

I have done some quick testing. Please let me know your results Thanks Claude ...

On Tue, Jun 21, 2022 at 3:22 AM Will Code @.***> wrote:

Hi Claude, sorry to disturb you again, but probably you have faced this issue in the past...

If I use my PiCam 1.3 with a simple Python script, which generates a small website with live video stream in it, all is working fine...

Using 'speed-cam.py' results in

$ ./speed-cam.py

speed-cam.py 11.23 written by Claude Pageau Motion Track Largest Moving Object and Calculate Speed per Calibration.

Loading Wait ... 2022-06-21 09:16:52 ERROR Pi Camera Module Not Found supported=1 detected=1, libcamera interfaces=0 2022-06-21 09:16:52 ERROR if supported=0 Enable Camera per command sudo raspi-config 2022-06-21 09:16:52 ERROR if detected=0 Check Pi Camera Module is Installed Correctly 2022-06-21 09:16:52 ERROR speed-cam.py 11.23 Exiting Due to Error

What confuses me ist the part 'supported=1 detected=1, libcamera interfaces=0'

The last option must be new, cause I could not find anything related.

Using Raspberry Pi OS 32 Bit Buster```

$ uname -a Linux speedcam 5.15.48-v7+ #1563 SMP Fri Jun 17 19:07:53 BST 2022 armv7l GNU/Linux

and newest speed-cam version.

Regards. Will.

— Reply to this email directly, view it on GitHub https://github.com/pageauc/speed-camera/issues/118, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNPKZCJYFJTTQQYVEUUKTDVQFUSJANCNFSM5ZLIVQFA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- YouTube Channel at https://www.youtube.com/user/pageaucp http://www.youtube.com/user/pageaucp GitHub Repository at https://github.com/pageauc

-- YouTube Channel at https://www.youtube.com/user/pageaucp http://www.youtube.com/user/pageaucp GitHub Repository at https://github.com/pageauc

-- YouTube Channel at https://www.youtube.com/user/pageaucp http://www.youtube.com/user/pageaucp GitHub Repository at https://github.com/pageauc

will-code-for-pizza commented 2 years ago

Hi Claude... Many thanks for your work and effort..

All I can say is:

$ cat /etc/os-release 
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

I remember, that I did an

apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y

The last command is to get the latest kernel. It did NOT an upgrade to Bullseye...

$ cat /etc/apt/sources.list
deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi

So I am pretty sure to run speed-cam under Buster.

I will try an upgrade via "menubox" and let you know the result. By the way... My cam struggles with the loss of contact on the small chip which goes to the lens. But I have re-checked and all is fine. Sometimes this chip has to be fixed by pressing down a little bit...

Regards Will

will-code-for-pizza commented 2 years ago

After upgrade via "menubox" and reboot...

$ ./speed-cam.py
----------------------------------------------------------------------
speed-cam.py 11.26  written by Claude Pageau
Motion Track Largest Moving Object and Calculate Speed per Calibration.
----------------------------------------------------------------------
Loading  Wait ...
Checking Pi Camera Module using command - vcgencmd get_camera
Camera Status is supported=1 detected=0, libcamera interfaces=0
Checking supported and detected Status
Detected Problem with Pi Camera Module per detected=0,

  if supported=0 Enable Camera per command sudo raspi-config
  if detected=0 Check Pi Camera Module is Installed Correctly.

speed-cam.py 11.26 Exiting Due to Error

Probably I should set up a fresh Buster without "apt-get dist-upgrade"....

will-code-for-pizza commented 2 years ago

I have tried to comment out the check for the cam...

# -----------------------------
try:  # Add this check in case running on non RPI platform using web cam
    from picamera.array import PiRGBArray
    from picamera import PiCamera
except ImportError:
    WEBCAM = True
#if not WEBCAM:
#    # Check that pi camera module is installed and enabled
#    print("Checking Pi Camera Module using command - vcgencmd get_camera")
#    camResult = subprocess.check_output("vcgencmd get_camera", shell=True)
#    camResult = camResult.decode("utf-8")
#    camResult = camResult.replace("\n", "")
#    print("Camera Status is %s" % camResult)
#    print("Checking supported and detected Status")
#    params = camResult.split()
#    for x in range(0,2):
#        if params[x].find("0") >= 0:
#            print("Detected Problem with Pi Camera Module per %s" % params[x])
#            print("")
#            print("  if supported=0 Enable Camera per command sudo raspi-config")
#            print("  if detected=0 Check Pi Camera Module is Installed Correctly.")
#            print("")
#            print("%s %s Exiting Due to Error" % ( progName, progVer))
#            sys.exit(1)
#    else:
#        print("Success Pi Camera Module is Enabled and Connected %s" % camResult)

try:  # Check to see if opencv is installed

Result:

$ ./speed-cam.py
----------------------------------------------------------------------
speed-cam.py 11.26  written by Claude Pageau
Motion Track Largest Moving Object and Calculate Speed per Calibration.
----------------------------------------------------------------------
Loading  Wait ...
2022-06-22 12:06:54 INFO     <module>   Initializing Pi Camera ....
mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM)
mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1)
2022-06-22 12:06:54 ERROR    __init__   PiCamera Already in Use by Another Process
2022-06-22 12:06:54 ERROR    __init__   speed-cam.py 11.26 Exiting Due to Error
will-code-for-pizza commented 2 years ago

Probably my attempt

sudo rpi-update was the problem... --> new version of 'vcgencmd'

will-code-for-pizza commented 2 years ago

I have downgraded 'vcgencmd' from libraspberrypi-bin_1.20220308~buster-1_armhf.deb to libraspberrypi-bin_1.20180328-1~nokernel1_armhf.deb

but it results in

$ vcgencmd get_camera
supported=1 detected=0, libcamera interfaces=0

I just wonder to stil see the "libcamera interfaces=0"

pageauc commented 2 years ago

When you enable the legacy picamera interface (proprietary) the libcamera interface (open source) is disabled and visa versa Only one interface at a time can have access to the camera. They are developing a new libcamera picamera2 python library. Currently in development. speed camera uses the picamera python module based on mmal api (proprietary broadcom application programming interface)

Looks like the legacy picamera interface is enabled but looks like a problem accessing the camera. Check the cables and reseat would be my advice. Make sure the camera module connection is firmly pushed in on the camera board since I have also had problems with one camera with that issue.

Speed camera does not currently run under libcamera interface but once the picamera2 python module is out of testing I plan to add.. Claude ....

On Thu, Jun 23, 2022 at 5:31 AM Will Code @.***> wrote:

I have downgraded 'vcgencmd' from libraspberrypi-bin_1.20220308buster-1_armhf.deb to libraspberrypi-bin_1.20180328-1nokernel1_armhf.deb

but it results in

$ vcgencmd get_camera supported=1 detected=0, libcamera interfaces=0

I just wonder to stil see the "libcamera interfaces=0"

— Reply to this email directly, view it on GitHub https://github.com/pageauc/speed-camera/issues/118#issuecomment-1164175840, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNPKZCARWTBEQWLPKO6PF3VQQVGXANCNFSM5ZLIVQFA . You are receiving this because you commented.Message ID: @.***>

-- YouTube Channel at https://www.youtube.com/user/pageaucp http://www.youtube.com/user/pageaucp GitHub Repository at https://github.com/pageauc

pageauc commented 1 year ago

Yes I have one camera module like that where the contact on the camera has to be pushed down. I will try dist-upgrade to see if the libcam entry is added. I have changed the code so it just checks the first two entries for the camera using vcgencmd get_camera. I did run speed camera on the latest Bullseye with the raspi-config legacy pi camera setting enabled. Speed camera runs OK. I am planning to update the github readme. Claude ...

On Wed, Jun 22, 2022 at 4:31 AM Will Code @.***> wrote:

Hi Claude... Many thanks for your work and effort..

All I can say is:

$ cat /etc/os-release PRETTY_NAME="Raspbian GNU/Linux 10 (buster)" NAME="Raspbian GNU/Linux" VERSION_ID="10" VERSION="10 (buster)" VERSION_CODENAME=buster ID=raspbian ID_LIKE=debian HOME_URL="http://www.raspbian.org/" SUPPORT_URL="http://www.raspbian.org/RaspbianForums" BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

I remember, that I have did an

apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y

The last command is to get the latest kernel. It did NOT an upgrade to Bullseye...

$ cat /etc/apt/sources.list deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi

So I am pretty sure to run speed-cam under Buster.

I will try an upgrade via "menubox" and let you know the result. By the way... My cam struggles with the loss of contact on the small chip which goes to the lens. But I have re-checked and all is fine. Sometimes this chip has to be fixed by pressing down a little bit...

Regards Will

— Reply to this email directly, view it on GitHub https://github.com/pageauc/speed-camera/issues/118#issuecomment-1162809933, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNPKZFZPB3LW2EMWL26QMDVQLFNNANCNFSM5ZLIVQFA . You are receiving this because you commented.Message ID: @.***>

-- YouTube Channel at https://www.youtube.com/user/pageaucp http://www.youtube.com/user/pageaucp GitHub Repository at https://github.com/pageauc