Failing to lock exposure on Logitech C270

asked 2019-06-29 00:13:48 -0600

doctrucker gravatar image

updated 2020-03-23 05:20:33 -0600

LBerger gravatar image

Hi all,

Go easy on me I'm from the python world and only recently started needing to compile outside of the Arduino IDE!

I'm trying to lock the auto exposure. I've found & modified a simple python test script that runs, but fails to lock the exposure:

import cv2
cap = cv2.VideoCapture(1)
print("before setting CAP_PROP_AUTO_EXPOSURE = %s" % cap.get(cv2.CAP_PROP_AUTO_EXPOSURE))
cap.set(cv2.CAP_PROP_AUTO_EXPOSURE, 0)
print("after setting CAP_PROP_AUTO_EXPOSURE = %s" % cap.get(cv2.CAP_PROP_AUTO_EXPOSURE))
print("before setting CAP_PROP_EXPOSURE = %s" % cap.get(cv2.CAP_PROP_AUTO_EXPOSURE))
cap.set(cv2.CAP_PROP_EXPOSURE,-4)
print("after setting CAP_PROP_EXPOSURE = %s" % cap.get(cv2.CAP_PROP_AUTO_EXPOSURE))
while(True):
    ret, frame = cap.read()
    cv2.imshow('frame',frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()

That doesn't work. I see the following warnings:

[ WARN:0] global /home/wesbrooks/horus3/opencv/modules/videoio/src/cap_gstreamer.cpp (924) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
[ WARN:0] global /home/wesbrooks/horus3/opencv/modules/videoio/src/cap_gstreamer.cpp (1175) setProperty OpenCV | GStreamer warning: GStreamer: unhandled property
[ WARN:0] global /home/wesbrooks/horus3/opencv/modules/videoio/src/cap_gstreamer.cpp (1025) getProperty OpenCV | GStreamer warning: unhandled property: 21
[ WARN:0] global /home/wesbrooks/horus3/opencv/modules/videoio/src/cap_gstreamer.cpp (1025) getProperty OpenCV | GStreamer warning: unhandled property: 15

I can run this on the command prompt before it and the exposure is locked:

v4l2-ctl -d /dev/video1 -c exposure_auto=1 -c exposure_auto_priority=0 -c exposure_absolute=10

The cmake options are:

cmake -D CMAKE_BUILD_TYPE=RELEASE \
            -D CMAKE_INSTALL_PREFIX=$cwd/installation/OpenCV-"$cvVersion" \
            -D INSTALL_C_EXAMPLES=ON \
            -D INSTALL_PYTHON_EXAMPLES=ON \
            -D WITH_TBB=ON \
            -D WITH_V4L=ON \
            -D OPENCV_PYTHON3_INSTALL_PATH=$cwd/OpenCV-$cvVersion-py3/lib/python3.6/site-packages \
            -D WITH_QT=ON \
            -D WITH_OPENGL=ON \
            -D BUILD_EXAMPLES=ON ..

My compile at the moment has the following errors or test failures:

-- Performing Test HAVE_CXX_WMISSING_PROTOTYPES - Failed
-- Performing Test HAVE_CXX_WSTRICT_PROTOTYPES - Failed
-- Performing Test HAVE_C_WSIGN_PROMO - Failed
-- Performing Test HAVE_C_WSUGGEST_OVERRIDE - Failed
-- Performing Test HAVE_C_WNO_DELETE_NON_VIRTUAL_DTOR - Failed
-- Performing Test HAVE_CXX_WNO_UNNAMED_TYPE_TEMPLATE_ARGS - Failed
-- Performing Test HAVE_C_WNO_UNNAMED_TYPE_TEMPLATE_ARGS - Failed
-- Performing Test HAVE_C_FVISIBILITY_INLINES_HIDDEN - Failed
-- Performing Test HAVE_CXX_WNO_INCONSISTENT_MISSING_OVERRIDE - Failed
-- Performing Test HAVE_CXX_WNO_MISSING_PROTOTYPES - Failed
-- Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
-- Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
-- Could NOT find Atlas (missing: Atlas_CLAPACK_INCLUDE_DIR) 
-- Performing Test HAVE_CXX_WNO_TAUTOLOGICAL_UNDEFINED_COMPARE - Failed
-- Performing Test HAVE_CXX_WNO_SHORTEN_64_TO_32 - Failed
-- Performing Test HAVE_CXX_WNO_ENUM_COMPARE_SWITCH - Failed
-- Could NOT find Flake8 (missing: FLAKE8_EXECUTABLE) 
-- VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
-- Caffe:   NO
-- Protobuf:   NO
-- Could NOT find HDF5 (missing: HDF5_LIBRARIES HDF5_INCLUDE_DIRS) (found version "")
-- Module opencv_ovis disabled because OGRE3D was not found
-- No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
--   No package 'tesseract' found
-- Tesseract:   NO
-- Performing Test HAVE_CXX_WNO_UNUSED_PRIVATE_FIELD - Failed

The general configuration output is:

-- General configuration for OpenCV 4.1.1-pre =====================================
--   Version control:               4.1.0-473-g453466eb1
-- 
--   Extra modules:
--     Location (extra):            /home/wesbrooks/horus3/opencv_contrib/modules
--     Version control (extra):     4.1.0-65-g3830f186
-- 
--   Platform ...
(more)
edit retag flag offensive close merge delete

Comments

I think I may have been wasting my time with the recompiles. I think it is related to this bug, but I can't check it yet as I'm out and about:

https://github.com/opencv/opencv/issu...

doctrucker gravatar imagedoctrucker ( 2019-06-29 08:46:47 -0600 )edit

I have changed the backend from the standard gstreamer and it is working. I will post an answer next week but looks to me like opencv isn't using the gsteamer backend properly as per the link in my previous comment.

doctrucker gravatar imagedoctrucker ( 2019-07-04 07:21:30 -0600 )edit

@doctrucker hi, I'm facing the same issue with : GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1.

How did you resolve it ? Still waiting for your "next week" answer. Thanks again !

raisa_ gravatar imageraisa_ ( 2020-03-23 05:17:18 -0600 )edit