nischi / MMM-Face-Reco-DNN

Face recognition with opencv and deep neural network
MIT License
90 stars 46 forks source link

Failed to create component 'vc.ril.camera' (1:ENOMEM) #116

Closed VedadTr closed 1 year ago

VedadTr commented 1 year ago

Hi ! Love the module idea, and i was planning on using it on my project, but i have encountered some errors. They just might be a mistake on my side, since this is my first time working with Raspberry and Linux.

I have installed OpenCV, and im using Raspberry Pi 3 b+ with the regular camera module. I tested the camera using raspistill - o and it works.

To my understanding, i just make a new folder called dataset in module folder, make another folder with the person name, and fill it with images. Then i run the encode python script, which creates encodings.pickle ? The pickle file is there, but i did not edit the python script, was i supposed to ?

After adding the module in the Mirror Config file, i start the mirror via npm start, and get a black screen. Nothing happens when i point the camera, and the terminal shows this:

error.txt

VedadTr commented 1 year ago

Here's the whole terminal log here too:

magicmirror@2.21.0 start DISPLAY="${DISPLAY:=:0}" ./node_modules/.bin/electron js/electron.js

[10.11.2022 02:09.34.105] [LOG] Starting MagicMirror: v2.21.0 [10.11.2022 02:09.34.118] [LOG] Loading config ... [10.11.2022 02:09.34.134] [LOG] Loading module helpers ... [10.11.2022 02:09.34.141] [LOG] No helper found for module: alert. [10.11.2022 02:09.34.184] [LOG] Initializing new module helper ... [10.11.2022 02:09.34.187] [LOG] Module helper loaded: updatenotification [10.11.2022 02:09.34.189] [LOG] No helper found for module: clock. [10.11.2022 02:09.34.923] [LOG] Initializing new module helper ... [10.11.2022 02:09.34.927] [LOG] Module helper loaded: calendar [10.11.2022 02:09.34.930] [LOG] No helper found for module: compliments. [10.11.2022 02:09.34.933] [LOG] No helper found for module: weather. [10.11.2022 02:09.35.006] [LOG] Initializing new module helper ... [10.11.2022 02:09.35.007] [LOG] Module helper loaded: newsfeed [10.11.2022 02:09.35.034] [LOG] Initializing new module helper ... [10.11.2022 02:09.35.035] [LOG] Module helper loaded: MMM-Face-Reco-DNN [10.11.2022 02:09.35.037] [LOG] All module helpers loaded. [10.11.2022 02:09.35.370] [LOG] Starting server on port 8080 ... [10.11.2022 02:09.35.407] [LOG] Server started ... [10.11.2022 02:09.35.410] [LOG] Connecting socket for: updatenotification [10.11.2022 02:09.35.411] [LOG] Starting module helper: updatenotification [10.11.2022 02:09.35.413] [LOG] Connecting socket for: calendar [10.11.2022 02:09.35.414] [LOG] Starting node helper for: calendar [10.11.2022 02:09.35.415] [LOG] Connecting socket for: newsfeed [10.11.2022 02:09.35.417] [LOG] Starting node helper for: newsfeed [10.11.2022 02:09.35.418] [LOG] Connecting socket for: MMM-Face-Reco-DNN [10.11.2022 02:09.35.419] [LOG] Starting module helper: MMM-Face-Reco-DNN [10.11.2022 02:09.35.421] [LOG] Sockets connected & modules started ... [10.11.2022 02:09.35.962] [LOG] Launching application. [3935:1110/020937.682438:ERROR:viz_main_impl.cc(186)] Exiting GPU process due to errors during initialization [3976:1110/020937.941771:ERROR:gpu_memory_buffer_support_x11.cc(44)] dri3 extension not supported. [3941:1110/020937.992366:ERROR:command_buffer_proxy_impl.cc(126)] ContextResult::kTransientFailure: Failed to send GpuControl.CreateCommandBuffer. [10.11.2022 02:09.40.863] [LOG] Create new calendarfetcher for url: http://www.calendarlabs.com/ical-calendar/ics/76/US_Holidays.ics - Interval: 300000 [10.11.2022 02:09.40.957] [LOG] Create new newsfetcher for url: https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml - Interval: 300000 [10.11.2022 02:09.41.082] [INFO] Checking git for module: MMM-Face-Reco-DNN [10.11.2022 02:09.41.148] [INFO] Checking git for module: default [10.11.2022 02:09.41.865] [INFO] Newsfeed-Fetcher: Broadcasting 32 items. [10.11.2022 02:09.42.420] [INFO] Calendar-Fetcher: Broadcasting 17 events. [10.11.2022 02:09.55.908] [LOG] [MMM-Face-Reco-DNN] loading encodings + face detector... [10.11.2022 02:09.56.106] [LOG] [MMM-Face-Reco-DNN] starting video stream... [10.11.2022 02:09.57.270] [ERROR] Whoops! There was an uncaught exception... [10.11.2022 02:09.57.341] [ERROR] PythonShellError: 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) Traceback (most recent call last): File "/usr/lib/python3/dist-packages/picamera/camera.py", line 456, in _init_camera self._camera = mo.MMALCamera() File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 2279, in init super(MMALCamera, self).init() File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 631, in init mmal_check( File "/usr/lib/python3/dist-packages/picamera/exc.py", line 184, in mmal_check raise PiCameraMMALError(status, prefix) picamera.exc.PiCameraMMALError: Failed to create MMAL component b'vc.ril.camera': Out of memory

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/vedadtr/MagicMirror/modules/MMM-Face-Reco-DNN/tools/facerecognition.py", line 85, in vs = VideoStream(usePiCamera=True, rotation=args["rotateCamera"]).start() File "/home/vedadtr/.local/lib/python3.9/site-packages/imutils/video/videostream.py", line 17, in init self.stream = PiVideoStream(resolution=resolution, File "/home/vedadtr/.local/lib/python3.9/site-packages/imutils/video/pivideostream.py", line 10, in init self.camera = PiCamera() File "/usr/lib/python3/dist-packages/picamera/camera.py", line 431, in init self._init_camera(camera_num, stereo_mode, stereo_decimate) File "/usr/lib/python3/dist-packages/picamera/camera.py", line 459, in _init_camera raise PiCameraError( picamera.exc.PiCameraError: Camera is not enabled. Try running 'sudo raspi-config' and ensure that the camera has been enabled.

at PythonShell.parseError (/home/vedadtr/MagicMirror/modules/MMM-Face-Reco-DNN/node_modules/python-shell/index.js:254:21)
at terminateIfNeeded (/home/vedadtr/MagicMirror/modules/MMM-Face-Reco-DNN/node_modules/python-shell/index.js:129:32)
at ChildProcess.<anonymous> (/home/vedadtr/MagicMirror/modules/MMM-Face-Reco-DNN/node_modules/python-shell/index.js:121:13)
at ChildProcess.emit (node:events:526:28)
at ChildProcess._handle.onexit (node:internal/child_process:291:12) {

executable: 'python3', options: null, script: 'modules/MMM-Face-Reco-DNN/tools/facerecognition.py', args: [ '--cascade=modules/MMM-Face-Reco-DNN/tools/haarcascade_frontalface_default.xml', '--encodings=modules/MMM-Face-Reco-DNN/tools/encodings.pickle', '--usePiCamera=1', '--source=0', '--rotateCamera=0', '--method=dnn', '--detectionMethod=hog', '--interval=2000', '--output=0', '--extendDataset=False', '--dataset=modules/MMM-Face-Reco-DNN/dataset/', '--tolerance=0.6' ], exitCode: 1 } [10.11.2022 02:09.57.368] [ERROR] MagicMirror² will not quit, but it might be a good idea to check why this happened. Maybe no internet connection? [10.11.2022 02:09.57.370] [ERROR] If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues

nischi commented 1 year ago

hi @VedadTr

Yes this encode.pickle file is then automatic generated on images in the subfolders. that sounds right.

about your second error. not sure whats happening there. can you send me your config of my module? did you installed opencv directly or with a virtual python environment? Did you test it if opencv is installed properly and python has access to it?

greets nischi

VedadTr commented 1 year ago

@nischi Thanks for the quick reply ! I installed open cv following your steps: https://pyimagesearch.com/2018/09/26/install-opencv-4-on-your-raspberry-pi/ Following the steps, i couldn't compile the program using make or make -j4, since the pi would always crash or display some errors.

So i installed OpenCV using - pip install opencv-python . I tested the installation using python3, import cv2, cv2.version. it seems to be installed just fine...

Now for the mirror config file, im dropping it in pastebin down below:

https://pastebin.com/9mnGF6E1?fbclid=IwAR3_7TVRz6HiYsFSYr_r3JQw9qHkaossZSNDum0uBtqWHb1avnB6gC8S9Gw

VedadTr commented 1 year ago

I manage to fix the problem by unplugging and plugging the camera on...

nischi commented 1 year ago

oh okay :) a reboot is always good :) but then i will close this issue