motioneye-project / motioneyeos

A Video Surveillance OS For Single-board Computers
Other
7.8k stars 893 forks source link

Rpi4 IMX219 Camera Detected and auto setup as MMAL but "Unable to open Video Device" #2909

Open jhall0326 opened 2 years ago

jhall0326 commented 2 years ago

Preliminary Docs

I confirm that I have read the CONTRIBUTING guide before opening this issue.

I confirm that I have read the FAQ before opening this issue.

motionEyeOS Version

I am running motionEyeOS version: 20201026.

Board Model

I am using the following board/model: Raspberry Pi 4 B.

Camera

I am using the following type of camera: MMAL.

My camera model is: IMX219.

Network Connection

My motionEyeOS unit is connected to the network via: WiFi.

Log Files

Log Files are attached.

Rpi4 Motioneyeos dev20201026 imx219. Camera works fine on a Bullseye build. vcgencmd get_camera reports supported=1 detected=1. MotioneEyeOS detects it and sets it up as MMAL Camera with Camera Device=vc.ril.camera but within the MotionEyeOS GUI it is a gray square saying "Unable to open video device.

I purchased 2 of these cameras and they both have the same issue. They work fine using libcamera-still but Unable to open video device in MEYEOS.

This is an exert from motion.log. All logs are attached.

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) [1:ml1:Camera1] [ERR] [VID] create_camera_component: Failed to create MMAL camera component vc.ril.camera [1:ml1:Camera1] [ERR] [VID] vid_start: MMAL cam failed to open 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) [1:ml1:Camera1] [ERR] [VID] create_camera_component: Failed to create MMAL camera component vc.ril.camera [1:ml1:Camera1] [ERR] [VID] vid_start: MMAL cam failed to open [1:ml1:Camera1] [WRN] [ALL] motion_init: Could not fetch initial image from camera [1:ml1:Camera1] [WRN] [ALL] motion_init: Motion continues using width and height from config file(s) [1:ml1:Camera1] [WRN] [ALL] mlp_retry: Retrying until successful connection with camera

05/18/2022 - I just received a 5 MP Arducam with image sensor OV5647 and plugged it into my MotionEyeOS Pi 4 and it worked out of the box. The IMX519 & IMX219 will not work properly but the OV5647 works perfectly. Can someone please help me resolve this issue since I need to get the IMX 519 working with MotionEyeOS. - Thanks,

jhall0326 commented 2 years ago

Log Files Attached:

motion.log dmesg.log boot.log messages.log motioneye.log

starbasessd commented 2 years ago

I notice that in dmesg log it is overloaded with the PixArt Gaming Mouse constantly being re-discovered. I would try to take that off the Pi, first. Are you manually setting any settings? Like wireless, or camera? What have you set frame rate, and resolution to? If you have monitor and keyboard attached (don't need / can't use a mouse anyway) can you run vcgencmd get_throttled and vcgencmd get_camera and report results, please?

jhall0326 commented 2 years ago

starbasessd - Thanks a ton for your assistance with this issue.

I have no manual settings at all. MeyeOS detects the IMX219 and sets it up as a MMAL camera name camera1, camera device=vc.ril.camera, camera type=MMAL

I've tried every frame rate and currently left it a 2 fps.

I remover monitor, keyboard and mouse and rebooted and attached new logs.

[root@meye-29481b76 lib]# vcgencmd get_throttled throttled=0x0

[root@meye-29481b76 ~]# vcgencmd get_camera supported=1 detected=1

motioneye (2).log motion (4).log dmesg (2).log boot (2).log messages (2).log

starbasessd commented 2 years ago

Let's force clear the logs, so we're not looking at a lot of old data:

logrotate /etc/logrotate.conf

reboot then post the logs. I am wondering if the IMX cameras are newer than the kernel in mEOS dev20201026 (like some of the new 16MP and higher resolution that weren't yet supported in the dev20201026 kernel. If that is the case (and looking more likely since the 5MP camera DOES work) you may have to wait for the new developers to post a new version (with updated kernel). Another way to test this thought is to install an older version of RPiOS (Pre-Bullseye) like maybe: archive releases 24/08/2020 If this image is 'broken' for the IMX but works on the 5MP, then the odds that it's not in the kernel just went way up...

jhall0326 commented 2 years ago

That certainly sounds like what I'm dealing with. Unsupported camera for the driver version.

I was very encouraged when I saw vcgencmd get_camera report detected=1 supported=1 but i'm not certain exactly what that means.

motioneye (3).log motion (5).log dmesg (5).log boot (3).log messages (3).log

jhall0326 commented 2 years ago

Also, when I delete and recreate the camera, I am now seeing under Camera Type=local V4L2 Camera, when I click the dropdown for camera, there is an entry at the bottom that used to not be there called "mmal service 16.1. When I choose this option, I get the same symptom.

starbasessd commented 2 years ago

Your logs didn't reset (or you are not grabbing the latest/current files) Want to give the kernel check test a go? Load the RPiOS from 24 Aug 2020? Do NOT add any additional drivers, as it is difficult to impossible to do so in mEOS.

starbasessd commented 2 years ago

vcgencmd get_camera basically says is there something on the CSI port, and does it support a query command. Doesn't mean all the functions are there or that the data is in the correct format, though, which is what the errors in the log files are showing.

jhall0326 commented 2 years ago

I finally got the logs to clear using the --force switch. I'm loading the RPi OS and will let you know when it is done. By the way, the camera works great in Bullseye.

motion (8).log boot (4).log dmesg (7).log messages (4).log motioneye (4).log

starbasessd commented 2 years ago

Bullseye is the 'latest and greatest', and motionEyeOS has been somewhat neglected for almost 2 years (new devs are working hard to correct the python2 vs python3 issues currently and will move into mEOS here soon)

starbasessd commented 2 years ago

4.163245] bcm2835-v4l2: V4L2 device registered as video0 - stills mode > 1280x720 I would recommend 1280x720 (if the IMX camera is attached during this log's boot)

jhall0326 commented 2 years ago

After setting to 1280X720 then reboot. New logs.

motion (9).log dmesg (8).log boot (5).log messages (5).log motioneye (5).log

starbasessd commented 2 years ago

I think we're chasing our own tail here. What happened with RPiOS Buster 24 Aug 2020?

jhall0326 commented 2 years ago

It took me a while to find it and download it. Getting ready to create the img now.

starbasessd commented 2 years ago

I put links to it above...

jhall0326 commented 2 years ago

Okay! It's booted and camera enabled. Now what?

starbasessd commented 2 years ago

Try raspivid or even install motionEye for Raspberry Pi from here: https://github.com/motioneye-project/motioneye/wiki/Install-On-Raspbian

jhall0326 commented 2 years ago

pi@raspberrypi:~ $ raspivid -bash: raspivid: command not found

starbasessd commented 2 years ago

I don't think you grabbed the correct image. it's this one: https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2020-08-24/

jhall0326 commented 2 years ago

sudo pip install motioneye Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Collecting motioneye Downloading https://files.pythonhosted.org/packages/c5/ff/139b4b02ed089b2b50eee65d1059ae0d29064ab5f4ad429e45c702396697/motioneye-0.42.1.tar.gz (758kB) 100% |████████████████████████████████| 768kB 579kB/s Requirement already satisfied: jinja2 in /usr/lib/python2.7/dist-packages (from motioneye) (2.10) Requirement already satisfied: pillow in /usr/lib/python2.7/dist-packages (from motioneye) (5.4.1) Collecting pycurl (from motioneye) Downloading https://files.pythonhosted.org/packages/ef/05/4b773f74f830a90a326b06f9b24e65506302ab049e825a3c0b60b1a6e26a/pycurl-7.43.0.5.tar.gz (216kB) 100% |████████████████████████████████| 225kB 1.5MB/s Complete output from command python setup.py egg_info: Traceback (most recent call last): File "", line 1, in File "/tmp/pip-install-j2562o/pycurl/setup.py", line 961, in ext = get_extension(sys.argv, split_extension_source=split_extension_source) File "/tmp/pip-install-j2562o/pycurl/setup.py", line 623, in get_extension ext_config = ExtensionConfiguration(argv) File "/tmp/pip-install-j2562o/pycurl/setup.py", line 101, in init self.configure() File "/tmp/pip-install-j2562o/pycurl/setup.py", line 238, in configure_unix raise ConfigurationError(msg) main.ConfigurationError: Could not run curl-config: [Errno 2] No such file or directory

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-j2562o/pycurl/ pi@raspberrypi:~ $

starbasessd commented 2 years ago

Building a Pi3B+ machine, stand by...

starbasessd commented 2 years ago

Also under thunderstorm, will be back shortly.

starbasessd commented 2 years ago

BTW, quick test. I installed 08/2020 image from link just above, without doing anything else, ran command:

raspivid

pi@raspberrypi:~ $ raspivid

"raspivid" Camera App (commit f97b1af1b3e6 Tainted)

Display camera output to display, and optionally saves an H264 capture at requested bitrate

usage: raspivid [options]

Image parameter commands

-b, --bitrate : Set bitrate. Use bits per second (e.g. 10MBits/s would be -b 10000000) -t, --timeout : Time (in ms) to capture for. If not specified, set to 5s. Zero to disable -d, --demo : Run a demo mode (cycle through range of camera options, no capture) -fps, --framerate : Specify the frames per second to record -e, --penc : Display preview image after encoding (shows compression artifacts) -g, --intra : Specify the intra refresh period (key frame rate/GoP size). Zero to produce an initial I-frame and then just P-frames. -pf, --profile : Specify H264 profile to use for encoding -td, --timed : Cycle between capture and pause. -cycle on,off where on is record time and off is pause time in ms -s, --signal : Cycle between capture and pause on Signal -k, --keypress : Cycle between capture and pause on ENTER -i, --initial : Initial state. Use 'record' or 'pause'. Default 'record' -qp, --qp : Quantisation parameter. Use approximately 10-40. Default 0 (off) -ih, --inline : Insert inline headers (SPS, PPS) to stream -sg, --segment : Segment output file in to multiple files at specified interval -wr, --wrap : In segment mode, wrap any numbered filename back to 1 when reach number -sn, --start : In segment mode, start with specified segment number -sp, --split : In wait mode, create new output file for each start event -c, --circular : Run encoded data through circular buffer until triggered then save -x, --vectors : Output filename for inline motion vectors -if, --irefresh : Set intra refresh type -fl, --flush : Flush buffers in order to decrease latency -pts, --save-pts : Save Timestamps to file for mkvmerge -cd, --codec : Specify the codec to use - H264 (default) or MJPEG -lev, --level : Specify H264 level to use for encoding -r, --raw : Output filename for raw video -rf, --raw-format : Specify output format for raw video. Default is yuv -l, --listen : Listen on a TCP socket -stm, --spstimings : Add in h.264 sps timings -sl, --slices : Horizontal slices per frame. Default 1 (off)

H264 Profile options : baseline,main,high

H264 Level options : 4,4.1,4.2

H264 Intra refresh options : cyclic,adaptive,both,cyclicrows

Raw output format options : yuv,rgb,gray

Raspivid allows output to a remote IPv4 host e.g. -o tcp://192.168.1.2:1234or -o udp://192.168.1.2:1234 To listen on a TCP port (IPv4) and wait for an incoming connection use the -l option e.g. raspivid -l -o tcp://0.0.0.0:3333 -> bind to all network interfaces, raspivid -l -o tcp://192.168.1.1:3333 -> bind to a certain local IPv4 port

Common Settings commands

-?, --help : This help information -w, --width : Set image width -h, --height : Set image height -o, --output : Output filename (to write to stdout, use '-o -'). If not specified, no file is saved -v, --verbose : Output verbose information during run -cs, --camselect : Select camera . Default 0 -md, --mode : Force sensor mode. 0=auto. See docs for other modes available -gps, --gpsdexif : Apply real-time GPS information to output (e.g. EXIF in JPG, annotation in video (requires libgps.so.23)

Preview parameter commands

-p, --preview : Preview window settings <'x,y,w,h'> -f, --fullscreen : Fullscreen preview mode -op, --opacity : Preview window opacity (0-255) -n, --nopreview : Do not display a preview window -dn, --dispnum : Display on which to display the preview window (dispmanx/tvservice numbering)

Image parameter commands

-sh, --sharpness : Set image sharpness (-100 to 100) -co, --contrast : Set image contrast (-100 to 100) -br, --brightness : Set image brightness (0 to 100) -sa, --saturation : Set image saturation (-100 to 100) -ISO, --ISO : Set capture ISO -vs, --vstab : Turn on video stabilisation -ev, --ev : Set EV compensation - steps of 1/6 stop -ex, --exposure : Set exposure mode (see Notes) -fli, --flicker : Set flicker avoid mode (see Notes) -awb, --awb : Set AWB mode (see Notes) -ifx, --imxfx : Set image effect (see Notes) -cfx, --colfx : Set colour effect (U:V) -mm, --metering : Set metering mode (see Notes) -rot, --rotation : Set image rotation (0-359) -hf, --hflip : Set horizontal flip -vf, --vflip : Set vertical flip -roi, --roi : Set region of interest (x,y,w,d as normalised coordinates [0.0-1.0]) -ss, --shutter : Set shutter speed in microseconds -awbg, --awbgains : Set AWB gains - AWB mode must be off -drc, --drc : Set DRC Level (see Notes) -st, --stats : Force recomputation of statistics on stills capture pass -a, --annotate : Enable/Set annotate flags or text -3d, --stereo : Select stereoscopic mode -dec, --decimate : Half width/height of stereo image -3dswap, --3dswap : Swap camera order for stereoscopic -ae, --annotateex : Set extra annotation parameters (text size, text colour(hex YUV), bg colour(hex YUV), justify, x, y) -ag, --analoggain : Set the analog gain (floating point) -dg, --digitalgain : Set the digital gain (floating point) -set, --settings : Retrieve camera settings and write to stdout -fw, --focus : Draw a window with the focus FoM value on the image.

Notes

Exposure mode options : off,auto,night,nightpreview,backlight,spotlight,sports,snow,beach,verylong,fixedfps,antishake,fireworks

Flicker avoid mode options : off,auto,50hz,60hz

AWB mode options : off,auto,sun,cloud,shade,tungsten,fluorescent,incandescent,flash,horizon,greyworld

Image Effect mode options : none,negative,solarise,sketch,denoise,emboss,oilpaint,hatch,gpen,pastel,watercolour,film,blur,saturation,colourswap,washedout,posterise,colourpoint,colourbalance,cartoon

Metering Mode options : average,spot,backlit,matrix

Dynamic Range Compression (DRC) options : off,low,med,high

starbasessd commented 2 years ago

Sorry, had thunderboomers, then had to feed grandkids. Finishing up:

sudo apt update && sudo apt upgrade -y

Following instructions from Wiki motionEye, Installs, Install on RaspberryPiOS Buster: https://github.com/motioneye-project/motioneye/wiki/Install-On-Raspbian Stage one:

sudo su apt-get install ffmpeg libmariadb3 libpq5 libmicrohttpd12 -y

completed successfully Stage two:

wget https://github.com/Motion-Project/motion/releases/download/release-4.3.2/pi_buster_motion_4.3.2-1_armhf.deb dpkg -i pi_buster_motion_4.3.2-1_armhf.deb

completed successfully Stage three

apt-get install python-pip python-dev libssl-dev libcurl4-openssl-dev libjpeg-dev libz-dev -y

completed successfully test which versions of python and pip are default:

python --version

Python 2.7.16

pip --version

pip 18.1 from /usr/lib/python2.7/dist-packages/pip (python 2.7) Stage four

pip install motioneye

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Collecting motioneye Downloading https://files.pythonhosted.org/packages/c5/ff/139b4b02ed089b2b50eee65d1059ae0d29064ab5f4ad429e45c702396697/motioneye-0.42.1.tar.gz (758kB) 100% |████████████████████████████████| 768kB 305kB/s Collecting jinja2 (from motioneye) Downloading https://files.pythonhosted.org/packages/7e/c2/1eece8c95ddbc9b1aeb64f5783a9e07a286de42191b7204d67b7496ddf35/Jinja2-2.11.3-py2.py3-none-any.whl (125kB) 100% |████████████████████████████████| 133kB 1.5MB/s Collecting pillow (from motioneye) Downloading https://files.pythonhosted.org/packages/b3/d0/a20d8440b71adfbf133452d4f6e0fe80de2df7c2578c9b498fb812083383/Pillow-6.2.2.tar.gz (37.8MB) 100% |████████████████████████████████| 37.8MB 6.5kB/s Collecting pycurl (from motioneye) Downloading https://files.pythonhosted.org/packages/ef/05/4b773f74f830a90a326b06f9b24e65506302ab049e825a3c0b60b1a6e26a/pycurl-7.43.0.5.tar.gz (216kB) 100% |████████████████████████████████| 225kB 778kB/s Collecting tornado<6,>=3.1 (from motioneye) Downloading https://files.pythonhosted.org/packages/e6/78/6e7b5af12c12bdf38ca9bfe863fcaf53dc10430a312d0324e76c1e5ca426/tornado-5.1.1.tar.gz (516kB) 100% |████████████████████████████████| 522kB 441kB/s Collecting MarkupSafe>=0.23 (from jinja2->motioneye) Downloading https://files.pythonhosted.org/packages/b9/2e/64db92e53b86efccfaea71321f597fa2e1b2bd3853d8ce658568f7a13094/MarkupSafe-1.1.1.tar.gz Collecting backports_abc>=0.4 (from tornado<6,>=3.1->motioneye) Downloading https://files.pythonhosted.org/packages/7d/56/6f3ac1b816d0cd8994e83d0c4e55bc64567532f7dc543378bd87f81cebc7/backports_abc-0.5-py2.py3-none-any.whl Collecting futures (from tornado<6,>=3.1->motioneye) Downloading https://files.pythonhosted.org/packages/d8/a6/f46ae3f1da0cd4361c344888f59ec2f5785e69c872e175a748ef6071cdb5/futures-3.3.0-py2-none-any.whl Collecting singledispatch (from tornado<6,>=3.1->motioneye) Downloading https://files.pythonhosted.org/packages/3f/09/2a17c6505a8373229cb3de6161e3af74ff90afcf4516719aa6cf32fad151/singledispatch-3.7.0-py2.py3-none-any.whl Requirement already satisfied: six in /usr/lib/python2.7/dist-packages (from singledispatch->tornado<6,>=3.1->motioneye) (1.12.0) Building wheels for collected packages: motioneye, pillow, pycurl, tornado, MarkupSafe Running setup.py bdist_wheel for motioneye ... done Stored in directory: /root/.cache/pip/wheels/b1/b5/20/266f8871b2b1f598c96a17e5545a16f2c2198956890f17fb5e Running setup.py bdist_wheel for pillow ... done Stored in directory: /root/.cache/pip/wheels/f6/0a/7c/5e6567101a10388b915c4ebf73edb849f73908ad154e9eb9bc Running setup.py bdist_wheel for pycurl ... done Stored in directory: /root/.cache/pip/wheels/98/a3/19/9439c79b88a742f508af0c4e410ae3f685db2e13d3374e798e Running setup.py bdist_wheel for tornado ... done Stored in directory: /root/.cache/pip/wheels/6d/e1/ce/f4ee2fa420cc6b940123c64992b81047816d0a9fad6b879325 Running setup.py bdist_wheel for MarkupSafe ... done Stored in directory: /root/.cache/pip/wheels/f2/aa/04/0edf07a1b8a5f5f1aed7580fffb69ce8972edc16a505916a77 Successfully built motioneye pillow pycurl tornado MarkupSafe Installing collected packages: MarkupSafe, jinja2, pillow, pycurl, backports-abc, futures, singledispatch, tornado, motioneye Successfully installed MarkupSafe-1.1.1 backports-abc-0.5 futures-3.3.0 jinja2-2.11.3 motioneye-0.42.1 pillow-6.2.2 pycurl-7.43.0.5 singledispatch-3.7.0 tornado-5.1.1

Stage five

mkdir -p /etc/motioneye cp /usr/local/share/motioneye/extra/motioneye.conf.sample /etc/motioneye/motioneye.conf

Stage six

mkdir -p /var/lib/motioneye

Stage seven, fini

cp /usr/local/share/motioneye/extra/motioneye.systemd-unit-local /etc/systemd/system/motioneye.service systemctl daemon-reload systemctl enable motioneye systemctl start motioneye


Reboot, camera (CSI RPiCam V2) discovered, no issue, working.

jhall0326 commented 2 years ago

I'm going to reimage SD Card and start over.

SWEBergmania commented 2 years ago

Some IMX219 CSI cameras do not work on a Rasberry Pi.. as stated on waveshares web "Because of the encryption, the IMX219 series cameras cannot be used with a Raspberry Pi board like the Raspberry Pi 4B, please note it."

Will only work on a CM or a Jetson..

I have a imx219 csi module (Waveshare IMX219-160) that works fine on a jetson nano.. but will not work correctly on a rpi3/4.. My mistake buying it really as I didn't look this up before.. and I already have a imx477 based module for the Jetson..