DietPi with Octoprint: How to Use Attached CSI Camera

Greets All!
I decided to install DietPi on a RPI4 4GB with Octoprint. I cannot believe I went this long without knowing about DietPi, and it’s awesome! Anyway, I have an attached CSI camera, an Arducam IMX519 16mb auto focus, and after some work, got it to work great.

Now my first question is, how can I use that CSI camera in Octoprint? And my second question… is there built-in streaming support in DietPi for that CSI camera? The second question actually deals with my need to also use DietPi and the same CSI camera for a NVR project, unrelated to my 3D printer RPI4.

Thanks!

Found this
https://docs.arducam.com/Raspberry-Pi-Camera/Native-camera/OctoPrint/

Thanks for the link. Apparently, if I read other issues with this correctly, it’s a problem with my development environment. And all I did was sudo apt install cmake after having errors. After installing cmake, I get this when I enter ‘make’…
EDIT: I am not using OctoPi either, but rather DietPi.

hop@:~/mjpg-streamer-libcamera/mjpg-streamer-experimental$ sudo make
[ -d _build ] || mkdir _build
[ -f _build/Makefile ] || (cd _build && cmake  -DCMAKE_BUILD_TYPE=Release ..)
CMAKE_BUILD_TYPE = Release
CMake Warning at plugins/input_opencv/CMakeLists.txt:4 (find_package):
  By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "OpenCV", but
  CMake did not find one.

  Could not find a package configuration file provided by "OpenCV" with any
  of the following names:

    OpenCVConfig.cmake
    opencv-config.cmake

  Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
  "OpenCV_DIR" to a directory containing one of the above files.  If "OpenCV"
  provides a separate development package or SDK, be sure it has been
  installed.


CMake Warning (dev) at /usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:273 (message):
  The package name passed to `find_package_handle_standard_args` (PkgConfig)
  does not match the name of the calling package (Gphoto2).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  /usr/share/cmake-3.18/Modules/FindPkgConfig.cmake:59 (find_package_handle_standard_args)
  cmake/FindGphoto2.cmake:21 (include)
  plugins/input_ptp2/CMakeLists.txt:2 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
CMake Warning (dev) at /usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:273 (message):
  The package name passed to `find_package_handle_standard_args` (GPHOTO2)
  does not match the name of the calling package (Gphoto2).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/FindGphoto2.cmake:44 (find_package_handle_standard_args)
  plugins/input_ptp2/CMakeLists.txt:2 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Could NOT find GPHOTO2 (missing: GPHOTO2_LIBRARY GPHOTO2_INCLUDE_DIR)
CMake Error at /usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
  Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
Call Stack (most recent call first):
  /usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:458 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.18/Modules/FindPkgConfig.cmake:59 (find_package_handle_standard_args)
  plugins/input_libcamera/CMakeLists.txt:1 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/hop/mjpg-streamer-libcamera/mjpg-streamer-experimental/_build/CMakeFiles/CMakeOutput.log".
make: *** [Makefile:18: all] Error 1

might be missing some pre-requisite apps…like Gphoto2, might need to install that one, then try again
Other than that…you have to get drivers to get a regular kernel/drivers to see the camera

I got the camera working. There were some issues with libcamera but I fixed that and all is good, even the autofocus.
What I am having issues with is compiling the code on jacksonliam/mjpg-streamer. I get errors when I try to make. And I read about all sorts of causes so I am trying to sort that out. It’s an old offering though so maybe not the best solution. I just also realized that the package I was using was not the correct one. The correct one for me was ArduCAM/mjpg-streamer, not jacksonliam/mjpg-streamer. Anyway, the only issue I have now, and cannot find anything via google, is that a preview window does not appear on my desktop when I run the streamer on a terminal. I get no warnings that there is no display available at all. But at LEAST I have a great stream at 30 FPS at 640x480.
Also, the focus is a bit off on the stream, but stills are crystal clear. I am now working that issue.
Another thing worth mentioning… the documentation for the input_libcamera.so plugin is not up-to-date to show autofocus features. The github shows one thing but when -h is used in a terminal, the added features and arguments are included.

OLD:

./mjpg_streamer -i "input_libcamera.so -h"

 ---------------------------------------------------------------
 Help for input plugin..: Libcamera Input plugin
 ---------------------------------------------------------------
 The following parameters can be passed to this plugin:

 [-r | --resolution ]...: the resolution of the video device,
                          can be one of the following strings:
                          QQVGA QCIF CGA QVGA CIF PAL VGA 
                          SVGA XGA HD SXGA UXGA FHD 

                          or a custom value like the following
                          example: 640x480
 [-f | --fps ]..........: frames per second
 [-b | --buffercount ]...: Set the number of request buffers.
 [-q | --quality ] .....: set quality of JPEG encoding
 [-s | --snapshot ] .....: Set the snapshot resolution, if not set will default to the maximum resolution.
 ---------------------------------------------------------------
 Optional parameters (may not be supported by all cameras):

 [-br ].................: Set image brightness (integer)
 [-co ].................: Set image contrast (integer)
 [-sa ].................: Set image saturation (integer)
 [-ex ].................: Set exposure (integer)
 [-gain ]...............: Set gain (integer)
 ---------------------------------------------------------------

NEW:

 ---------------------------------------------------------------
 Help for input plugin..: Libcamera Input plugin
 ---------------------------------------------------------------
 The following parameters can be passed to this plugin:

 [-r | --resolution ]...: the resolution of the video device,
                          can be one of the following strings:
                          QQVGA QCIF CGA QVGA CIF PAL
                          VGA SVGA XGA HD SXGA UXGA
                          FHD
                          or a custom value like the following
                          example: 640x480
 [-c | --camera ].......: Chooses the camera to use.
 [-f | --fps ]..........: frames per second
 [-b | --buffercount ]...: Set the number of request buffers.
 [-q | --quality ] .....: set quality of JPEG encoding
 [-rot | --rotation]....: Request an image rotation, 0 or 180
 [-s | --snapshot ] .....: Set the snapshot resolution, if not set will default to the maximum resolution.
 ---------------------------------------------------------------
 Optional parameters (may not be supported by all cameras):

 [-br ].................: Set image brightness (integer)
 [-co ].................: Set image contrast (integer)
 [-sa ].................: Set image saturation (integer)
 [-ex ].................: Set exposure (integer)
 [-gain ]...............: Set gain (integer)
 [-afmode]..............: Control to set the mode of the AF (autofocus) algorithm.(manual, auto, continuous)
 [-afrange].............: Set the range of focus distances that is scanned.(normal, macro, full)
 [-lensposition]........: Set the lens to a particular focus position, expressed as a reciprocal distance (0 moves the lens to infinity), or "default" for the hyperfocal distance ---------------------------------------------------------------

Thanks for the replies and the nudge in the right direction!!! You are a life saver!!

1 Like

Thanks for the followup…the devs are the hero’s…making such a great distro!