Issue 1:
System information (version)

OpenCV => master

Operating System / Platform => Windows 64 Bit

Compiler => Visual Studio 15 2017 Win64

Detailed description

When doing Configure on master branch in Windows with CV_DISABLE_OPTIMIZATION checked, it causes the CMake configuration process to fail on errors like these:

CMake Error at cmake/OpenCVUtils.cmake:331 (target_include_directories):
Cannot specify include directories for target "opencv_test_core_SSE4_1"
which is not built by this project.
Call Stack (most recent call first):
cmake/OpenCVModule.cmake:675 (ocv_target_include_directories)
cmake/OpenCVModule.cmake:1239 (ocv_target_include_modules)
modules/core/CMakeLists.txt:97 (ocv_add_accuracy_tests)

CMake Error at cmake/OpenCVUtils.cmake:331 (target_include_directories):
Cannot specify include directories for target "opencv_test_core_SSE4_2"
which is not built by this project.
Call Stack (most recent call first):
cmake/OpenCVModule.cmake:675 (ocv_target_include_directories)
cmake/OpenCVModule.cmake:1239 (ocv_target_include_modules)
modules/core/CMakeLists.txt:97 (ocv_add_accuracy_tests)

.....

and many more of the same error for the various components that are selected for building.

Steps to reproduce

In Windows 10 x64, CMake (v3.7.2), clone the repo, checkout master branch, and run CMake Configure with Visual Studio 15 2017 Win64 as the compiler.

Issue 2:
System information (version)

OpenCV => 4.1.2

Operating System / Platform => Linux / Ubuntu 18.04

Compiler => ❔

Detailed description

When running the code below that call solvePnPGeneric from Python the program crashes because the C++ code expect a different type for reprojectionError from the one passed by solvePnPGeneric by default. The argument is however documented as optional. Passing the argument with the correct type avoid the error.

I suspect that the binding of the solvePnPGeneric function do not pass the correct argument type for reprojectionError by default.

The error:

Traceback (most recent call last):
File "error.py", line 15, in <module>
obj_points, img_points, cameraMatrix, distCoeffs #, reprojectionError=r
cv2.error: OpenCV(4.1.2) /io/opencv/modules/calib3d/src/solvepnp.cpp:1017: error: (-2:Unspecified error) in function 'int cv::solvePnPGeneric(cv::InputArray, cv::InputArray, cv::InputArray, cv::InputArray, cv::OutputArrayOfArrays, cv::OutputArrayOfArrays, bool, cv::SolvePnPMethod, cv::InputArray, cv::InputArray, cv::OutputArray)'
> Type of reprojectionError must be CV_32FC1 or CV_64FC1!:
> 'type == CV_32FC1 || type == CV_64FC1'
> where
> 'reprojectionError.type()' is 0 (CV_8UC1)

This might be closely linked to #16040 which is about Java binding of solvePnPGeneric

Steps to reproduce

Run this code (OpenCV 4.1.2 / Python 3.6.8)

import numpy as np
import cv2

obj_points = np.array([[0, 0, 0], [0, 1, 0], [1, 1, 0], [1, 0, 0]], dtype=np.float32)
img_points = np.array(
[[700, 400], [700, 600], [900, 600], [900, 400]], dtype=np.float32
)

cameraMatrix = np.array(
[[712.0634, 0, 800], [0, 712.540, 500], [0, 0, 1]], dtype=np.float32
)
distCoeffs = np.array([[0, 0, 0, 0]], dtype=np.float32)
#r = np.array([], dtype=np.float32)
x, r, t, e = cv2.solvePnPGeneric(
obj_points, img_points, cameraMatrix, distCoeffs #, reprojectionError=r
)
print(e)
print(t)

The error can be bypassed by uncommenting the #r = np.array([], dtype=np.float32) lines.

Thanks for the amazing work and happy to help or provide more information!