using opencv::cuda::demosaicing() without cuda sdk installed - c++

this is my make file,
from Cuda image processing module, I would like to use demosaicing()
I'm am building cuda on my own. and do not want to use the cuda sdk
i'm using openCV 3.0.0 version
default:
#echo Makefile targets are clean, build and rebuild
BUILD_DIR=build_dir
clean:
# Do nothing so that developers can do "clean" or "rebuild" solution without
# forcing to rebuild also OpenCV. Below is documented what the "clean" should do
# if it were to be enabled.
# -rmdir /Q /S $(BUILD_DIR)
build: $(BUILD_DIR)\lib\$(CONFIGURATION)
rebuild: clean build
$(BUILD_DIR)\lib\$(CONFIGURATION): $(BUILD_DIR)\OpenCV.sln
-cd $(BUILD_DIR)
devenv OpenCV.sln /build "$(CONFIGURATION)|x64" /project ALL_BUILD
devenv OpenCV.sln /build "$(CONFIGURATION)|x64" /project INSTALL
$(BUILD_DIR)\OpenCV.sln:
if not exist $(BUILD_DIR) (mkdir $(BUILD_DIR) )
cd $(BUILD_DIR)
cmake \
-D BUILD_SHARED_LIBS=FALSE \
-D BUILD_opencv_apps=FALSE \
-D BUILD_DOCS=FALSE \
-D BUILD_PACKAGE=FALSE \
-D BUILD_PERF_TESTS=FALSE \
-D BUILD_TESTS=FALSE \
-D BUILD_FAT_JAVA_LIB=FALSE \
-D BUILD_opencv_python2=FALSE \
-D BUILD_opencv_python3=FALSE \
-D BUILD_WITH_STATIC_CRT=OFF \
-D WITH_FFMPEG=OFF \
-D WITH_IPP=OFF \
-D WITH_OPENCL=OFF \
-D BUILD_CUDA_STUBS=ON \
-G "Visual Studio 12 2013 Win64" \
$(SolutionDir)\3rdparty\opencv
the error i'm getting is
..opencv\modules\cudaimgproc\src\histogram.cpp(58): error C2244: 'histEven' : unable to match function definition to an existing declaration

Related

CMake Cross compile Arm64 error “unrecognised command line option ‘-msse’”

I am trying to cross-compile openCV for an Arm64 linux platform and am getting the following errors
aarch64-linux-gnu-gcc: error: unrecognised command line option ‘-msse’; did you mean ‘-fdse’?
aarch64-linux-gnu-gcc: error: unrecognised command line option ‘-msse2’
aarch64-linux-gnu-gcc: error: unrecognised command line option ‘-msse3’
I understand that the -msse flags are not compatible with arm64, yet when I generate my makefile from CMake, these flags are include.
My CMake command is
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-DCUDA_NVCC_EXECUTABLE=/usr/local/cuda-10/bin/nvcc \
-DCUDA_HOST_COMPILER=/opt/l4t-gcc-toolchain-64-bit-32-7.1/bin/aarch64-linux-gnu-gcc \
-DCUDA_INCLUDE_DIRS=/usr/local/cuda-10/targets/aarch64-linux/include \
-DCUDA_CUDART_LIBRARY=/usr/local/cuda-10/targets/aarch64-linux/lib/libcudart.so \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D BUILD_EXAMPLES=OFF \
-D WITH_CUDA=ON \
-D CUDA_ARCH_BIN="6.2" \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.4.0/modules/ \
-D ENABLE_CXX11=ON ..
I am building on linux ubuntu 18.4.
How to do I tell CMake that the platform is Arm64?
Thanks
I resolved the issue, the missing flag I was looking for was
-D CMAKE_TOOLCHAIN_FILE=../platforms/linux/aarch64-gnu.toolchain.cmake

Building LLVM toolchain Stops midway through

So I am atempting to build the ARA-RISCV build and it requires a RISC-V LLVM toolchain and they give you a "make toolchain-llvm" command and it starts off ok but midway through the build around 2500/3500 it stops and the terminal closes without pointing out any error while it builds.
The command that are used are the ones below:
mkdir -p /.../rvv/install/riscv-llvm
cd /.../rvv/toolchain/riscv-llvm && rm -rf build && mkdir -p build && cd build && \
cmake -G Ninja \
-DCMAKE_INSTALL_PREFIX=/home/alex/Documents/Project/rvv/install/riscv-llvm \
-DLLVM_ENABLE_PROJECTS="clang;lld" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=gcc \
-DCMAKE_CXX_COMPILER=g++ \
-DLLVM_DEFAULT_TARGET_TRIPLE=riscv64-unknown-elf \
-DLLVM_TARGETS_TO_BUILD="RISCV" \
../llvm
cd /.../rvv/toolchain/riscv-llvm && \
cmake --build build --target install
After everything the build is incomplete and a lot of files have not been downloaded.I dont know what is causing this can anybody help?
Please and thank you.
EDIT:It worked by adding -j8 to the last instruction aka
cmake --build build --target install -j8

Building opencv from source in Mac m1

I'm using the following Make to build OpenCV from source,
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=/Users/Tools/opencv_contrib/modules \
-D PYTHON3_EXECUTABLE=/miniforge/base/envs/envname/bin/python3 \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_python3=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D WITH_TBB=ON \
-D WITH_V4L=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_ENABLE_NONFREE=ON \
-D WITH_OPENGL=ON \
-DBUILD_ZLIB=OFF \
-D OPENCV_EXTRA_MODULES_PATH=/Users/Tools/opencv_contrib/modules \
-D BUILD_EXAMPLES=ON ..
Unfortunately it doesn't build. It throws the following error,
: error: unknown type name 'AVBSFContext'; did you mean 'AVIOContext'?
I have of course installed FFmpeg. what am I still missing?
I think that you've installed ffmpeg 5 and OpenCV is not yet compatible with it. Please try the following:
brew install ffmpeg#4
brew unlink ffmpeg
brew link ffmpeg#4
and then recompile OpenCV again.

Correct iOS architecture names for autotools?

What are the standard architecture names of mobile platforms, namely ARM-based, for autotools?
I've tried to build some C/C++ libs for iOS including arm64, armv7, and iOS simulators (i386 and x86_64), but I always ended up having identical binaries for arm64 and x86_64-simulator, which in turns fails the universal binary build by lipo. I've tried to set the --build and --host switches to one of the following pairs
For arm64: --build=x86_64-apple-darwinuname -r, --host=arm64
For x86_64-simulator: --build=x86_64-apple-darwinuname -r, --host=x86_64-apple-darwinuname -r
To my surprise, running the following script,
## Environments
ScriptDir="$( cd "$( dirname "$0" )" && pwd )"
cd - &> /dev/null
# Exit the build pass if any command returns a non-zero value
#set -o errexit
# Echo commands
set -x
DARWIN=darwin`uname -r`
MIN_SDK_VERSION=8.0
IPHONEOS_SYSROOT=`xcrun --sdk iphoneos --show-sdk-path`
IPHONESIMULATOR_SYSROOT=`xcrun --sdk iphonesimulator --show-sdk-path`
# Verbose clang output
#CLANG_VERBOSE="--verbose"
CC=/usr/bin/clang
CXX=/usr/bin/clang
SILENCED_WARNINGS="-Wno-unused-local-typedef -Wno-unused-function"
STDLIB=libc++
CFLAGS="${CLANG_VERBOSE} ${SILENCED_WARNINGS} -DNDEBUG -g -O0 -pipe -fPIC -fcxx-exceptions"
CXXFLAGS="${CFLAGS} -std=c++11 -stdlib=${STDLIB}"
LDFLAGS="-stdlib=${STDLIB}"
LIBS="-lc++ -lc++abi"
PROTOC=`which protoc`
SOURCE_DIR="$ScriptDir"
PREFIX="$ScriptDir"/_build
if [ -d ${PREFIX} ]
then
rm -rf "${PREFIX}"
fi
mkdir -p "${PREFIX}/platform" &> /dev/null
## Functions
build_arch() {
HOST=$1
ARCH=$2
PLATFORM_CFLAGS=$3
PLATFORM_NAME=${ARCH}
SYSROOT=${IPHONEOS_SYSROOT}
ARCH_BITS=x86_64
if [[ $ARCH==armv7 || $ARCH==armv7s ]]; then
ARCH_BITS=i386
fi
CC="${CC}"
CFLAGS="${CFLAGS} -miphoneos-version-min=${MIN_SDK_VERSION} -arch ${ARCH} -isysroot ${SYSROOT} ${PLATFORM_CFLAGS}" \
CXX="${CXX}" \
CXXFLAGS="${CXXFLAGS} -miphoneos-version-min=${MIN_SDK_VERSION} -arch ${ARCH} -isysroot ${SYSROOT}" \
LDFLAGS="-arch ${ARCH} -miphoneos-version-min=${MIN_SDK_VERSION} ${LDFLAGS}" \
LIBS="${LIBS}" \
./configure \
--without-gcc \
--disable-ld-version-script \
--build=x86_64-apple-${DARWIN} \
--host=${HOST} \
--with-protoc=${PROTOC} \
--disable-shared \
--prefix=${PREFIX} \
--exec-prefix=${PREFIX}/platform/${PLATFORM_NAME}
make -j8
make install
}
build_simulator() {
ARCH=$1
PLATFORM_CFLAGS=$2
HOST=${ARCH}-apple-${DARWIN}
PLATFORM_NAME=${ARCH}-simulator
SYSROOT=${IPHONESIMULATOR_SYSROOT}
CC="${CC}" \
CFLAGS="${CFLAGS} -mios-simulator-version-min=${MIN_SDK_VERSION} -arch ${ARCH} -isysroot ${SYSROOT} ${PLATFORM_CFLAGS}" \
CXX="${CXX}" \
CXXFLAGS="${CXXFLAGS} -mios-simulator-version-min=${MIN_SDK_VERSION} -arch ${ARCH} -isysroot ${SYSROOT}" \
LDFLAGS="-arch ${ARCH} -mios-simulator-version-min=${MIN_SDK_VERSION} ${LDFLAGS}" \
LIBS="${LIBS}" \
./configure \
--without-gcc \
--disable-ld-version-script \
--build=x86_64-apple-${DARWIN} \
--host=${HOST} \
--with-protoc=${PROTOC} \
--disable-shared \
--prefix=${PREFIX} \
--exec-prefix=${PREFIX}/platform/${PLATFORM_NAME}
make -j8
make install
}
build_fat_lib() {
OUT=${PREFIX}/universal
mkdir -p ${OUT}
PLATFORM_ROOT=${PREFIX}/platform
LIPO=lipo
LIB=libprotobuf.a
${LIPO} ${PLATFORM_ROOT}/arm64/lib/${LIB} \
${PLATFORM_ROOT}/x86_64-simulator/lib/${LIB} \
-create \
-output ${OUT}/${LIB}
LIB_LITE=libprotobuf-lite.a
${LIPO} ${PLATFORM_ROOT}/arm64/lib/${LIB_LITE} \
${PLATFORM_ROOT}/x86_64-simulator/lib/${LIB_LITE} \
-create \
-output ${OUT}/${LIB_LITE}
}
## Build pass
cd ${SOURCE_DIR}
./autogen.sh
build_simulator x86_64 "-fembed-bitcode"
build_arch arm arm64 "-fembed-bitcode"
build_fat_lib
echo DONE!
, I end up getting complaints from lipo:
+ lipo /path/to/protobuf/_build/platform/arm64/lib/libprotobuf.a /path/to/protobuf/_build/platform/x86_64-simulator/lib/libprotobuf.a -create -output /path/to/protobuf/_build/universal/libprotobuf.a
fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: /path/to/protobuf/_build/platform/arm64/lib/libprotobuf.a and /path/to/protobuf/_build/platform/x86_64-simulator/lib/libprotobuf.a have the same architectures (x86_64) and can't be in the same fat output file
My first impression is that I'm misusing architecture names, and I don't know where to get the standard names. Is that it?
Solved it myself.
It turns out that the real problem is not a wrong arch triplet, but an inappropriate compiler executable assigned to CC/CXX. You gotta use
SDK="iphoneos"
export CC=$(xcrun --find --sdk "${SDK}" clang)
export CXX=$(xcrun --find --sdk "${SDK}" clang++)
export CPP=$(xcrun --find --sdk "${SDK}" cpp)
GOTCHA #1
config.guess as suggested by #JohnBolinger will always return
x86_64-apple-darwin18.7.0
This leads to the wrong x86_64 build that I had before.
GOTCHA #2
Observe the Xcode build log and you may find -target arm64-apple-ios13.1 as a Clang option, not to be confused with the autotool configure option --target. This one is useless either, unfortunately.

Failed to link osmesa correctly

Mesa version = 12.0.1
Tried version before this as well.
At link time this error comes up: /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libGL.so: undefined reference to _glapi_tls_Dispatch'.
The script i am using to install mesa:
#!/bin/bash
make -j4 distclean # if in an existing build
autoreconf -fi
./configure \
CXXFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \
CFLAGS="-O2 -g -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \
--disable-xvmc \
--disable-glx \
--disable-dri \
--with-dri-drivers="" \
--with-gallium-drivers="swrast" \
--enable-texture-float \
--enable-shared-glapi \
--disable-egl \
--with-egl-platforms="" \
--enable-gallium-osmesa \
--enable-llvm-shared-libs=yes \
--enable-gallium-llvm=yes \
--prefix=/home/ec2-user/new-mesa/mesaBuild/
make -j2
make -j4 install
After installation :
Added prefix(defined in script) to /etc/ld.so.conf' and ran ldconfig
Then in link command: -Lprefix -lOSMesa
What am i doing wrong?