conservationtechlab / dencam

Polar bear maternal den observation system.
MIT License
5 stars 2 forks source link

Explore focusing tool #82

Open tonytonyhsiao opened 2 months ago

tonytonyhsiao commented 1 month ago

Installed the Dencam repo on a new Raspberry Pi, following the README file, but encountered the errors shown below:

After running pip install .[all], I had to manually open the setup.py file to install the dependencies individually. Successfully installed:

'minimalmodbus==2.0.1' 'netifaces' 'picamera' (install this first) 'pyserial' 'pyyaml' 'rpi.gpio' For the additional dependencies, I successfully installed numpy (but had to specify version 1.19.4).

However, I was unsuccessful in installing opencv, and it is also missing from the old Dencam SD card."

tonytonyhsiao commented 1 month ago

installed numpy dependency, put aside opencv for now. encounter numpy.core.multiarray failed to import while running examine_focus_w_frid_scipy.py

tonytonyhsiao commented 1 month ago

Refactor the old examine_focus_w_grid_scipy.py file to eliminate the existing bug. The current version(haven't pushed yet) successfully detects blur levels on a live camera feed using a grid overlay.

TODO: The current GUI is built with tkinter, which might be causing the lagging image issue. Consider replacing it to improve performance.

FUTURE: Explore installing OpenCV and possibly upgrading to a newer Raspberry Pi OS for enhanced functionality."

tonytonyhsiao commented 1 month ago

Steps to Successfully Install opencv:

  1. Check that the numpy version is 1.19.4.
  2. Run !pip install opencv-contrib-python==4.1.0.25.
  3. After running python -c "import cv2; print(cv2.__version__)", you might encounter an error indicating that libxxx is not found.
  4. Exit the virtual environment.
  5. Go to the directory: cd ~/.virtualenvs/dencam_env/lib/python3.7/site-packages/cv2. You should see a file named cv2.cpython-37m-arm-linux-gnueabihf.so.
  6. Run ldd cv2.cpython-37m-arm-linux-gnueabihf.so.
  7. You will see a list of .so files, some of which may show => not found.
  8. Run ldd cv2.cpython-37m-arm-linux-gnueabihf.so | grep "not found". This will filter out the existing files and only show the missing ones. For example: libhdf5_serial.so.103 => not found libsz.so.2 => not found.
  9. To find out which apt packages provide the missing .so files, use apt-file. Since apt-file isn’t installed by default, install it with: sudo apt install apt-file.
  10. Update apt-file's cache: sudo apt-file update.
  11. Use apt-file search to locate the missing .so file. For example: apt-file search libhdf5_serial.so.103.
  12. This will show a list of apt packages (including duplicates). For example: libhdf5-100: /usr/lib/arm-linux-gnueabihf/libhdf5_serial.so.100 libhdf5-100: /usr/lib/arm-linux-gnueabihf/libhdf5_serial.so.100.0.1
  13. This indicates that the package libhdf5-100 provides the required .so file for OpenCV. Install it: sudo apt install libhdf5-100.(the package shows ahead of the ":")
  14. Run the command again: python -c "import cv2; print(cv2.__version__)". Everything should now work correctly.
tonytonyhsiao commented 1 month ago

Resolved the lagging issue by switching from SciPy to OpenCV and removing Tkinter. I've created a branch and pushed the code.

tonytonyhsiao commented 1 month ago

changing the grid number by config file: SOLVED

TODO:

  1. Toggle button
  2. Test focus tool with Canon lens
  3. Picamera overlay for rendering
tonytonyhsiao commented 1 week ago

I've updated the focus tool code based on our last discussion (round, reduce the width, center the text, configure text size and transparency). I've also addressed part of the Pylint suggestions and added docstrings.