yoursunny / esp32cam

OV2640 camera on ESP32-CAM, Arduino library
https://esp32cam.yoursunny.dev
ISC License
473 stars 168 forks source link

Uploaded a Application example that uses the WifiCam example #19

Closed dolendravikas closed 3 weeks ago

dolendravikas commented 2 years ago

This is a python based application where the face and eye detection algorithms can be locally on the personal computer where this python file is running. The only thing care should be taken is that both the esp32 cam module and the personal computer should be connected to the same network.

yoursunny commented 2 years ago

I tested the application but could not get it to work.

$ docker run -it --rm --network host -v $(pwd):/app -w /app michaelbalser/python-opencv bash

root@sunnyJ:/app# lscpu
Architecture:        aarch64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
CPU(s):              4
On-line CPU(s) list: 0-3
Thread(s) per core:  1
Core(s) per socket:  4
Socket(s):           1
Vendor ID:           ARM
Model:               1
Model name:          Cortex-A57
Stepping:            r1p1
CPU max MHz:         1479.0000
CPU min MHz:         102.0000
BogoMIPS:            38.40
L1d cache:           128 KiB
L1i cache:           192 KiB
L2 cache:            2 MiB
Flags:               fp asimd evtstrm aes pmull sha1 sha2 crc32

root@sunnyJ:/app# apt update && apt install -y --no-install-recommends gdb

root@sunnyJ:/app# python --version
Python 3.9.7

root@sunnyJ:/app# pip install pipenv
Successfully installed backports.entry-points-selectable-1.1.0 certifi-2021.5.30 distlib-0.3.3 filelock-3.2.0 pipenv-2021.5.29 platformdirs-2.4.0 six-1.16.0 virtualenv-20.8.1 virtualenv-clone-0.5.7

root@sunnyJ:/app# cd extras/applications/FaceAndEyesDetection/

root@sunnyJ:/app/extras/applications/FaceAndEyesDetection# pipenv install
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.

root@sunnyJ:/app/extras/applications/FaceAndEyesDetection# pipenv run python Face\&EyesDetection.py 192.168.5.56
Illegal instruction (core dumped)

root@sunnyJ:/app/extras/applications/FaceAndEyesDetection# pipenv run gdb --silent --args python Face\&EyesDetection.py 192.168.5.56
Reading symbols from python...
(gdb) run
Starting program: /root/.local/share/virtualenvs/FaceAndEyesDetection-PV0Kz0Zw/bin/python Face\&EyesDetection.py 192.168.5.56
warning: Error disabling address space randomization: Operation not permitted
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".

Program received signal SIGILL, Illegal instruction.
0x0000007fa0d23f54 in gotoblas_dynamic_init ()
   from /root/.local/share/virtualenvs/FaceAndEyesDetection-PV0Kz0Zw/lib/python3.9/site-packages/numpy/core/../../numpy.libs/libopenblasp-r0-32ff4d91.3.13.so

I also tried distro-provided OpenCV packages, and it doesn't work either:

$ docker run -it --rm --network host -v $(pwd):/app -w /app debian:bullseye bash

root@sunnyJ:/app# apt update && apt install -y --no-install-recommends python3-opencv

root@sunnyJ:/app# python3
Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'4.5.1'

root@sunnyJ:/app# cd extras/applications/FaceAndEyesDetection/

root@sunnyJ:/app/extras/applications/FaceAndEyesDetection# python3 Face\&EyesDetection.py 192.168.5.56
Traceback (most recent call last):
  File "/app/extras/applications/FaceAndEyesDetection/Face&EyesDetection.py", line 22, in <module>
    cv2.data.haarcascades+'haarcascade_frontalface_default.xml')
AttributeError: module 'cv2' has no attribute 'data'