I'm trying to read and display an image using OpenCV c++ version in vscode but I keep getting this error:
libpng warning: Application built with libpng-1.4.12 but running with 1.6.37 libc++abi: terminating with uncaught exception of type cv::Exception: OpenCV(4.5.3) /opencv/opencv-4.5.3/modules/highgui/src/window.cpp:1006: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'
This is my CmakeLists:
cmake_minimum_required(VERSION 3.0.0)
project(C++ VERSION 0.1.0)
include(CTest)
include(FindPkgConfig)
enable_testing()
pkg_check_modules(LIBPNG libpng16 REQUIRED)
if (NOT LIBPNG_FOUND)
message(FATAL ERROR "libpng16 development libaries not installed")
endif()
message(PNG_LIBRARIES = "${LIBPNG_LIBRARIES}")
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS} ${LIBPNG_INCLUDE_DIRS})
link_directories(${LIBPNG_LIBRARY_DIRS})
add_executable(C++ main.cpp)
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS} ${LIBPNG_LIBRARIES})
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
The make file builds without error and finds the required but I still get the error. This is the build output: build_output
Any suggestions on this issue?