Access pinephone camera with opencv? 2

Not long ago @jackson opened a thread about this, but after successfully building pip wheels with gstreamer support, yet before testing them, the thread was closed.
So, any clue about this? Any brave one that want to test his wheels on they pinephone?

i also want to get opencv/v4l2 working on my pinephone i think the only solution is to wait

I don’t even remember exactly how I did it at this point. I remember using cmake to set flags which is where you can enable gstreamer, but not compiling it. Then by looking through the pip documentation I used whatever I got from that, to build a wheel. I still never tried it though. I haven’t turned my pinephone on in a long time. I will look through my notes in a little bit, sometimes I leave instructions for myself incase I need to do it again.

You probably need to adapt something to your own use case, but here are the general instructions I wrote down. I suggest using kde connect to copy the commands to your phone, after reading them carefully.

Build instructions for openc cv wheels.

git clone --recursive https://github.com/opencv/opencv-python.git
git clone https://github.com/opencv/opencv_contrib.git

Now, cd into your cloned “opencv” folder and make a directory named build to put the build files in there during “make” and then cd into the build folder.

mkdir build
cd build

now activate the venv

For gstreamer now run

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/home/admin/Documents/pyPro/py39_venv/lib/python3.9/site-packages INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=OFF -D OPENCV_ENABLE_NONFREE=ON -D OPENCV_EXTRA_MODULES_PATH=/home/admin/Documents/opencvbuild/opencv_contrib/modules -D PYTHON_EXECUTABLE=$(which python) -D BUILD_opencv_python2=OFF -D CMAKE_INSTALL_PREFIX=$(python -c "import sys; print(sys.prefix)") -D PYTHON3_EXECUTABLE=$(which python) -D PYTHON3_INCLUDE_DIR=$(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") -D PYTHON3_PACKAGES_PATH=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") -D WITH_GSTREAMER=ON -D BUILD_EXAMPLES=ON ..


when done

to create wheel

pip wheel . --verbose

Find the created wheels 2 levels up in the opencv-python directory.

To install the wheel in the active venv

python -m pip install './opencv_python-4.5.5.62-cp39-cp39-linux_x86_64.whl'