nareshmlx/opencv-pr huggingface dataset:
**File:** cmake/OpenCVDetectCUDAUtils.cmake
**Change Type:** added
**Context:** PR #23021: `cuda`: CMake add CUDA first class language support

**Code Changes:**
```diff
@@ -0,0 +1,442 @@
+macro(ocv_check_for_nvidia_video_codec_sdk cuda_toolkit_dirs)
+  macro(ocv_cuda_SEARCH_NVCUVID_HEADER _filename _result)
+    # place header file under CUDAToolkit_LIBRARY_ROOT
+    find_path(_header_result
+      ${_filename}
+      PATHS ${cuda_toolkit_dirs}
+      PATH_SUFFIXES include
+      NO_DEFAULT_PATH
+      )
```

Review comment:
CUDA_NVCC_EXECUTABLE is still used here
**File:** cmake/OpenCVDetectCUDA.cmake
**Change Type:** modified
**Context:** PR #23021: `cuda`: CMake add CUDA first class language support
**Review Line:** 135

**Code Changes:**
```diff
-        else()
-          list(APPEND CUDA_NVCC_FLAGS "--std=c++14")
-        endif()
+macro(ocv_check_windows_crt_linkage)
+  # The new MSVC runtime abstraction is only useable if CUDA is a first class language
+  if(WIN32 AND POLICY CMP0091)
+    cmake_policy(GET CMP0091 MSVC_RUNTIME_SET_BY_ABSTRACTION)
+    if(MSVC_RUNTIME_SET_BY_ABSTRACTION STREQUAL "NEW")
+      if(NOT BUILD_SHARED_LIBS AND BUILD_WITH_STATIC_CRT)
+        set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} " /MT")
+        set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG} " /MTd")
```

Review comment:
This code needs to be kept to auto set host compiler
**File:** CMakeLists.txt
**Change Type:** modified
**Context:** PR #23021: `cuda`: CMake add CUDA first class language support
**Review Line:** 678

**Code Changes:**
```diff
+
+    # Check CUDA_PATH if supplied
+    if(UNIX AND CUDA_PATH AND NOT ENV{CUDA_PATH})
+      set(ENV{CUDA_PATH} ${CUDA_PATH})
+    elseif(WIN32 AND CUDA_PATH)
+      set(ENV{PATH} "${CUDA_PATH}\\bin\;$ENV{PATH}")
+    endif()
+    include(CheckLanguage)
+    check_language(CUDA)
+
+    # Fallback to checking default locations
```

Review comment:
I cannot get this WIN32 path to work if CUDA_PATH is not set as an environment variable, setting CUDA_PATH as cmake variable does not work, check_language(CUDA) does not find the compiler. If [this](https://github.com/Kitware/CMake/blob/69f0dd42b063296ab96a3ab61392b36cadab04b8/Modules/CMakeDetermineCUDACompiler.cmake#L21) is what is run by check_language(CUDA) it only seems to look for the nvcc compiler in $ENV{CUDACXX} and $ENV{CUDA_PATH}/bin. Should ENV{CUDA_PATH} be set for windows too as done for UNIX two lines above?
**File:** CMakeLists.txt
**Change Type:** modified
**Context:** PR #23021: `cuda`: CMake add CUDA first class language support
**Review Line:** 678

**Code Changes:**
```diff
+
+    # Check CUDA_PATH if supplied
+    if(UNIX AND CUDA_PATH AND NOT ENV{CUDA_PATH})
+      set(ENV{CUDA_PATH} ${CUDA_PATH})
+    elseif(WIN32 AND CUDA_PATH)
+      set(ENV{PATH} "${CUDA_PATH}\\bin\;$ENV{PATH}")
+    endif()
+    include(CheckLanguage)
+    check_language(CUDA)
+
+    # Fallback to checking default locations
```

Review comment:
> I cannot get this WIN32 path to work if CUDA_PATH is not set as an environment variable, setting CUDA_PATH as cmake variable does not work, check_language(CUDA) does not find the compiler. This appears to be Visual Studio specific. If I use the Ninja generator instead then this works. VS appears to (I'm still checkig this now) rely on a hard coded environmental variable, which if deleted prevents it from finding the CUDA compiler. In your case this would be **CUDA_PATH_V12_3**.
**File:** CMakeLists.txt
**Change Type:** modified
**Context:** PR #23021: `cuda`: CMake add CUDA first class language support
**Review Line:** 678

**Code Changes:**
```diff
+
+    # Check CUDA_PATH if supplied
+    if(UNIX AND CUDA_PATH AND NOT ENV{CUDA_PATH})
+      set(ENV{CUDA_PATH} ${CUDA_PATH})
+    elseif(WIN32 AND CUDA_PATH)
+      set(ENV{PATH} "${CUDA_PATH}\\bin\;$ENV{PATH}")
+    endif()
+    include(CheckLanguage)
+    check_language(CUDA)
+
+    # Fallback to checking default locations
```

Review comment:
If you want to use the VS generator then you can pass the location of your CUDA toolkit directly to CMake using the [toolset specification](https://cmake.org/cmake/help/latest/variable/CMAKE_GENERATOR_TOOLSET.html#visual-studio-toolset-selection) (see [this](https://discourse.cmake.org/t/cuda-selction-with-visual-studio-generator/9535/3) post for more details). e.g. ``` -Tcuda="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3" ```
**File:** cmake/OpenCVDetectCUDA.cmake
**Change Type:** modified
**Context:** PR #23021: `cuda`: CMake add CUDA first class language support
**Review Line:** 135

**Code Changes:**
```diff
-        else()
-          list(APPEND CUDA_NVCC_FLAGS "--std=c++14")
-        endif()
+macro(ocv_check_windows_crt_linkage)
+  # The new MSVC runtime abstraction is only useable if CUDA is a first class language
+  if(WIN32 AND POLICY CMP0091)
+    cmake_policy(GET CMP0091 MSVC_RUNTIME_SET_BY_ABSTRACTION)
+    if(MSVC_RUNTIME_SET_BY_ABSTRACTION STREQUAL "NEW")
+      if(NOT BUILD_SHARED_LIBS AND BUILD_WITH_STATIC_CRT)
+        set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} " /MT")
+        set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG} " /MTd")
```

Review comment:
Added back in, in the latest commit, can you take a look if you have chance?
**File:** cmake/OpenCVCRTLinkage.cmake
**Change Type:** modified
**Context:** PR #23021: `cuda`: CMake add CUDA first class language support
**Review Line:** 56

**Code Changes:**
```diff
+      endif()
+      if(${flag_var} MATCHES "/MDd")
+        string(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}")
+      endif()
+    endforeach(flag_var)
+  endif()
 
   set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:atlthunk.lib")
   set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libcpmt.lib /NODEFAULTLIB:msvcrt.lib")
   set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:libcpmtd.lib /NODEFAULTLIB:msvcrtd.lib")
 else()
```

Review comment:
The same code block in else branch. Let's extract it outside.
**File:** cmake/OpenCVCRTLinkage.cmake
**Change Type:** modified
**Context:** PR #23021: `cuda`: CMake add CUDA first class language support
**Review Line:** 56

**Code Changes:**
```diff
+      endif()
+      if(${flag_var} MATCHES "/MDd")
+        string(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}")
+      endif()
+    endforeach(flag_var)
+  endif()
 
   set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:atlthunk.lib")
   set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libcpmt.lib /NODEFAULTLIB:msvcrt.lib")
   set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:libcpmtd.lib /NODEFAULTLIB:msvcrtd.lib")
 else()
```

Review comment:
Its not exactly the same. - if(...) replaces the flags for the dynamic CRT with the static one and - else() replaces the flags for the static CRT with the dynamic one. I didn't modify this part, but I can modify it to put the loop outside however I think the intent is clearer if the loops are inside the if/else condition?
**File:** cmake/OpenCVDetectCUDAUtils.cmake
**Change Type:** added
**Context:** PR #23021: `cuda`: CMake add CUDA first class language support
**Review Line:** 133

**Code Changes:**
```diff
+endmacro()
+
+macro(ocv_set_cuda_detection_nvcc_flags cuda_host_compiler_var)
+  if(OPENCV_CUDA_DETECTION_NVCC_FLAGS MATCHES "-ccbin")
+  # already specified by user
+  elseif(${cuda_host_compiler_var} AND EXISTS "${${cuda_host_compiler_var}}")
+    get_filename_component(c_compiler_realpath "${CMAKE_C_COMPILER}" REALPATH)
+    # C compiler doesn't work with --run option, forcing C++ compiler instead
+    if(${cuda_host_compiler_var} STREQUAL c_compiler_realpath OR ${cuda_host_compiler_var} STREQUAL CMAKE_C_COMPILER)
+      if(DEFINED CMAKE_CXX_COMPILER)
+        get_filename_component(cxx_compiler_realpath "${CMAKE_CXX_COMPILER}" REALPATH)
```

Review comment:
Upgraded our conan packaged solution to OpenCV 4.9.0. This EXISTS check requires that the full path to clang++ is specified, it's not possible to just set CMAKE_CUDA_HOST_COMPILER=clang++. A bit annoying but not a huge deal.
**File:** cmake/OpenCVDetectCUDAUtils.cmake
**Change Type:** added
**Context:** PR #23021: `cuda`: CMake add CUDA first class language support
**Review Line:** 133

**Code Changes:**
```diff
+endmacro()
+
+macro(ocv_set_cuda_detection_nvcc_flags cuda_host_compiler_var)
+  if(OPENCV_CUDA_DETECTION_NVCC_FLAGS MATCHES "-ccbin")
+  # already specified by user
+  elseif(${cuda_host_compiler_var} AND EXISTS "${${cuda_host_compiler_var}}")
+    get_filename_component(c_compiler_realpath "${CMAKE_C_COMPILER}" REALPATH)
+    # C compiler doesn't work with --run option, forcing C++ compiler instead
+    if(${cuda_host_compiler_var} STREQUAL c_compiler_realpath OR ${cuda_host_compiler_var} STREQUAL CMAKE_C_COMPILER)
+      if(DEFINED CMAKE_CXX_COMPILER)
+        get_filename_component(cxx_compiler_realpath "${CMAKE_CXX_COMPILER}" REALPATH)
```

Review comment:
Perhaps we might call `find_program` here? Or somewhere earlier.
**File:** modules/core/src/out.cpp
**Change Type:** modified
**Context:** PR #25015: Fixed possible out-of-bound access in cv::Mat output formatter

**Code Changes:**
```diff
@@ -342,9 +342,10 @@ namespace cv
 
         Ptr<Formatted> format(const Mat& mtx) const CV_OVERRIDE
         {
-            static const char* numpyTypes[] =
+            static const char* numpyTypes[CV_DEPTH_MAX] =
             {
-                "uint8", "int8", "uint16", "int16", "int32", "float32", "float64", "float16"
+                "uint8", "int8", "uint16", "int16", "int32", "float32", "float64",
+                "float16", "bfloat16", "bool", "uint64", "int64", "uint32"
```

Review comment:
please, change `numpyTypes[]` to `numpyTypes[CV_DEPTH_MAX]`
**File:** modules/objdetect/src/qrcode.cpp
**Change Type:** modified
**Context:** PR #25026: Fix qrcode bugs
**Review Line:** 482

**Code Changes:**
```diff
+                TermCriteria( TermCriteria::EPS + TermCriteria::COUNT, 10, 0.1),
+                3, KMEANS_PP_CENTERS, localization_points);
+
+            fixationPoints(localization_points);
+        }
+    }
 
-    fixationPoints(localization_points);
+    if (labels.empty())
+    {
+        localization_points.clear();
```

Review comment:
`localization_points` should be reset in else branches, if `kmeans`/`fixationPoints` do not happen.
**File:** modules/3d/src/pointcloud/io_ply.cpp
**Change Type:** modified
**Context:** PR #24961: PLY mesh support

**Code Changes:**
```diff
@@ -8,6 +8,8 @@
 #include <opencv2/core/utils/logger.hpp>
 #include <fstream>
 #include <string>
+#include <iomanip>
+#include <cstddef>
 
 namespace cv {
 
@@ -16,15 +18,16 @@ void PlyDecoder::readData(std::vector<Point3f> &points, std::vector<Point3f> &no
```

Review comment:
The solution looks suspicious. ``` file.read((char *)&val, sizeof(uchar)); ``` Depends on endianess. On big-endian you'll get something 0xFF000... and the result will be always zero.
**File:** modules/3d/src/pointcloud/io_ply.hpp
**Change Type:** modified
**Context:** PR #24961: PLY mesh support
**Review Line:** 43

**Code Changes:**
```diff
 
 protected:
     bool parseHeader(std::ifstream &file);
-    void parseBody(std::ifstream &file, std::vector<Point3f> &points, std::vector<Point3f> &normals, std::vector<Point3_<uchar>> &rgb);
+    void parseBody(std::ifstream &file, std::vector<Point3f> &points, std::vector<Point3f> &normals, std::vector<Point3_<uchar>> &rgb,
+                   std::vector<std::vector<int32_t>> &indices);
 
     DataFormat m_inputDataFormat;
     size_t m_vertexCount{0};
+    size_t m_faceCount{0};
     bool m_hasColour{false};
```

Review comment:
why not just int?
**File:** modules/3d/src/pointcloud/io_ply.cpp
**Change Type:** modified
**Context:** PR #24961: PLY mesh support

**Code Changes:**
```diff
@@ -8,6 +8,8 @@
 #include <opencv2/core/utils/logger.hpp>
 #include <fstream>
 #include <string>
+#include <iomanip>
+#include <cstddef>
 
 namespace cv {
 
@@ -16,15 +18,16 @@ void PlyDecoder::readData(std::vector<Point3f> &points, std::vector<Point3f> &no
```

Review comment:
Sure, gonna fix it
**File:** modules/3d/src/pointcloud/io_ply.hpp
**Change Type:** modified
**Context:** PR #24961: PLY mesh support
**Review Line:** 43

**Code Changes:**
```diff
 
 protected:
     bool parseHeader(std::ifstream &file);
-    void parseBody(std::ifstream &file, std::vector<Point3f> &points, std::vector<Point3f> &normals, std::vector<Point3_<uchar>> &rgb);
+    void parseBody(std::ifstream &file, std::vector<Point3f> &points, std::vector<Point3f> &normals, std::vector<Point3_<uchar>> &rgb,
+                   std::vector<std::vector<int32_t>> &indices);
 
     DataFormat m_inputDataFormat;
     size_t m_vertexCount{0};
+    size_t m_faceCount{0};
     bool m_hasColour{false};
```

Review comment:
For consistency purposes This data type is used everywhere across point cloud / mesh loading for indices
**File:** modules/3d/include/opencv2/3d.hpp
**Change Type:** modified
**Context:** PR #24961: PLY mesh support

**Code Changes:**
```diff
@@ -2785,12 +2785,15 @@ CV_EXPORTS_W void savePointCloud(const String &filename, InputArray vertices, In
 *
 * Currently, the following file formats are supported:
 * -  [Wavefront obj file *.obj](https://en.wikipedia.org/wiki/Wavefront_.obj_file) (ONLY TRIANGULATED FACES)
+* -  [Polygon File Format *.ply](https://en.wikipedia.org/wiki/PLY_(file_format))
 * @param filename Name of the file.
 * @param vertices (vector of Point3f) vertex coordinates of a mesh
-* @param normals (vector of Point3f) vertex normals of a mesh
 * @param indices (vector of vectors of int) vertex normals of a mesh
+* @param normals (vector of Point3f) vertex normals of a mesh
```

Review comment:
Why do we need overloads. Looks like the most complete function with default values is enough, e.g.: ``` CV_EXPORTS_W void saveMesh(const String &filename, InputArray vertices, InputArrayOfArrays indices, InputArray normals = noArray(), colors = noArray()); ```
**File:** modules/3d/include/opencv2/3d.hpp
**Change Type:** modified
**Context:** PR #24961: PLY mesh support

**Code Changes:**
```diff
@@ -2785,12 +2785,15 @@ CV_EXPORTS_W void savePointCloud(const String &filename, InputArray vertices, In
 *
 * Currently, the following file formats are supported:
 * -  [Wavefront obj file *.obj](https://en.wikipedia.org/wiki/Wavefront_.obj_file) (ONLY TRIANGULATED FACES)
+* -  [Polygon File Format *.ply](https://en.wikipedia.org/wiki/PLY_(file_format))
 * @param filename Name of the file.
 * @param vertices (vector of Point3f) vertex coordinates of a mesh
-* @param normals (vector of Point3f) vertex normals of a mesh
 * @param indices (vector of vectors of int) vertex normals of a mesh
+* @param normals (vector of Point3f) vertex normals of a mesh
```

Review comment:
Didn't want to change the existing API; But you're right, this one looks better, fixing it
**File:** modules/calib3d/src/usac/utils.cpp
**Change Type:** modified
**Context:** PR #24987: bug fix infinite loop

**Code Changes:**
```diff
@@ -169,6 +169,9 @@ class SolvePoly : public SolverPoly {
     int getRealRoots (const std::vector<double> &coeffs, std::vector<double> &real_roots) override {
         if (coeffs.empty())
             return 0;
+        for (auto c : coeffs)
+            if (cvIsNaN(c) || cvIsInf(c))
+                return 0;
         Poly input(coeffs);
         if (input.degree() < 1)
             return 0;
```

Review comment:
`cvIsNaN` (which properly works in case of `-ffast-math`) --- Inf?
**File:** modules/3d/test/test_rendering.cpp
**Change Type:** added
**Context:** PR #24459: Triangle rasterization function

**Code Changes:**
```diff
@@ -0,0 +1,948 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#include "test_precomp.hpp"
+
+namespace opencv_test { namespace {
+using namespace cv;
+
```

Review comment:
Please use path relative to `OPENCV_TEST_DATA_PATH`
**File:** modules/3d/perf/perf_rendering.cpp
**Change Type:** added
**Context:** PR #24459: Triangle rasterization function

**Code Changes:**
```diff
@@ -0,0 +1,344 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#include "perf_precomp.hpp"
+
+namespace opencv_test
+{
+
```

Review comment:
Just 0 or Scalar::all(0) can be used as the last parameter. Even better to use cv::Mat::zeros for it.
**File:** modules/3d/perf/perf_rendering.cpp
**Change Type:** added
**Context:** PR #24459: Triangle rasterization function

**Code Changes:**
```diff
@@ -0,0 +1,344 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#include "perf_precomp.hpp"
+
+namespace opencv_test
+{
+
```

Review comment:
I recommend to use cv::format for file name generation.
**File:** modules/3d/src/rendering.cpp
**Change Type:** added
**Context:** PR #24459: Triangle rasterization function

**Code Changes:**
```diff
@@ -0,0 +1,402 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#include "precomp.hpp"
+
+namespace cv {
+
+TriangleRasterizeSettings::TriangleRasterizeSettings()
```

Review comment:
`zInter` may be not initialized here.
**File:** modules/3d/src/rendering.cpp
**Change Type:** added
**Context:** PR #24459: Triangle rasterization function

**Code Changes:**
```diff
@@ -0,0 +1,402 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#include "precomp.hpp"
+
+namespace cv {
+
+TriangleRasterizeSettings::TriangleRasterizeSettings()
```

Review comment:
CV_Check or CV_Assert is better here.
**File:** modules/3d/perf/perf_rendering.cpp
**Change Type:** added
**Context:** PR #24459: Triangle rasterization function

**Code Changes:**
```diff
@@ -0,0 +1,344 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#include "perf_precomp.hpp"
+
+namespace opencv_test
+{
+
```

Review comment:
Makes sense, will fix this
**File:** modules/3d/include/opencv2/3d.hpp
**Change Type:** modified
**Context:** PR #24459: Triangle rasterization function

**Code Changes:**
```diff
@@ -2809,6 +2809,136 @@ CV_EXPORTS_W void loadMesh(const String &filename, OutputArray vertices, OutputA
 CV_EXPORTS_W void saveMesh(const String &filename, InputArray vertices, InputArrayOfArrays indices,
                            InputArray normals = noArray(), InputArray colors = noArray());
 
+
+//! Triangle fill settings
+enum TriangleShadingType
+{
+    RASTERIZE_SHADING_WHITE  = 0, //!< a white color is used for the whole triangle
+    RASTERIZE_SHADING_FLAT   = 1, //!< a color of 1st vertex of each triangle is used
```

Review comment:
I Propose to add an overload with standard Pinhole camera parameters: K and Distortion.
**File:** modules/3d/perf/perf_rendering.cpp
**Change Type:** added
**Context:** PR #24459: Triangle rasterization function

**Code Changes:**
```diff
@@ -0,0 +1,344 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#include "perf_precomp.hpp"
+
+namespace opencv_test
+{
+
```

Review comment:
formatting issue. We usually do not add extra tab for namespaces.
**File:** modules/3d/perf/perf_rendering.cpp
**Change Type:** added
**Context:** PR #24459: Triangle rasterization function

**Code Changes:**
```diff
@@ -0,0 +1,344 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#include "perf_precomp.hpp"
+
+namespace opencv_test
+{
+
```

Review comment:
Please use normalize() instead: https://docs.opencv.org/5.x/dc/d84/group__core__basic.html#ga1b6a396a456c8b6c6e4afd8591560d80
**File:** modules/3d/perf/perf_rendering.cpp
**Change Type:** added
**Context:** PR #24459: Triangle rasterization function

**Code Changes:**
```diff
@@ -0,0 +1,344 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#include "perf_precomp.hpp"
+
+namespace opencv_test
+{
+
```

Review comment:
Please use cv::normalize() instead: https://docs.opencv.org/5.x/dc/d84/group__core__basic.html#ga1b6a396a456c8b6c6e4afd8591560d80
**File:** modules/3d/perf/perf_rendering.cpp
**Change Type:** added
**Context:** PR #24459: Triangle rasterization function

**Code Changes:**
```diff
@@ -0,0 +1,344 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#include "perf_precomp.hpp"
+
+namespace opencv_test
+{
+
```

Review comment:
I propose to generalize the function and make it public API.
**File:** modules/3d/src/rendering.cpp
**Change Type:** added
**Context:** PR #24459: Triangle rasterization function

**Code Changes:**
```diff
@@ -0,0 +1,402 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#include "precomp.hpp"
+
+namespace cv {
+
+TriangleRasterizeSettings::TriangleRasterizeSettings()
```

Review comment:
It's often computed as double. It makes sense to support it too.
**File:** modules/3d/src/rendering.cpp
**Change Type:** added
**Context:** PR #24459: Triangle rasterization function

**Code Changes:**
```diff
@@ -0,0 +1,402 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#include "precomp.hpp"
+
+namespace cv {
+
+TriangleRasterizeSettings::TriangleRasterizeSettings()
```

Review comment:
copyTo/ConvertTo/initialize from .data ptr?
**File:** modules/3d/src/rendering.cpp
**Change Type:** added
**Context:** PR #24459: Triangle rasterization function

**Code Changes:**
```diff
@@ -0,0 +1,402 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#include "precomp.hpp"
+
+namespace cv {
+
+TriangleRasterizeSettings::TriangleRasterizeSettings()
```

Review comment:
`triangles.t();` happens 2 times in some cases.
**File:** modules/3d/src/rendering.cpp
**Change Type:** added
**Context:** PR #24459: Triangle rasterization function

**Code Changes:**
```diff
@@ -0,0 +1,402 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#include "precomp.hpp"
+
+namespace cv {
+
+TriangleRasterizeSettings::TriangleRasterizeSettings()
```

Review comment:
Is it still relevant?