Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/zxing-cpp/core/src/GridSampler.h @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 /* | |
| 2 * Copyright 2016 Nu-book Inc. | |
| 3 * Copyright 2016 ZXing authors | |
| 4 */ | |
| 5 // SPDX-License-Identifier: Apache-2.0 | |
| 6 | |
| 7 #pragma once | |
| 8 | |
| 9 #include "DetectorResult.h" | |
| 10 #include "PerspectiveTransform.h" | |
| 11 | |
| 12 namespace ZXing { | |
| 13 | |
| 14 /** | |
| 15 * Samples an image for a rectangular matrix of bits of the given dimension. The sampling | |
| 16 * transformation is determined by the coordinates of 4 points, in the original and transformed | |
| 17 * image space. | |
| 18 * | |
| 19 * The following figure is showing the layout a 'pixel'. The point (0,0) is the upper left corner | |
| 20 * of the first pixel. (1,1) is its lower right corner. | |
| 21 * | |
| 22 * 0 1 ... w | |
| 23 * 0 #----#-- ... --# | |
| 24 * | | ... | | |
| 25 * | | ... | | |
| 26 * 1 #----# ... --# | |
| 27 * | | ... | | |
| 28 * | |
| 29 * | | ... | | |
| 30 * h #----#-- ... --# | |
| 31 * | |
| 32 * @param image image to sample | |
| 33 * @param width width of {@link BitMatrix} to sample from image | |
| 34 * @param height height of {@link BitMatrix} to sample from image | |
| 35 * @param mod2Pix transforming a module (grid) coordinate into an image (pixel) coordinate | |
| 36 * @return {@link DetectorResult} representing a grid of points sampled from the image within a region | |
| 37 * defined by the "src" parameters. Result is empty if transformation is invalid (out of bound access). | |
| 38 */ | |
| 39 DetectorResult SampleGrid(const BitMatrix& image, int width, int height, const PerspectiveTransform& mod2Pix); | |
| 40 | |
| 41 template <typename PointT = PointF> | |
| 42 Quadrilateral<PointT> Rectangle(int x0, int x1, int y0, int y1, typename PointT::value_t o = 0.5) | |
| 43 { | |
| 44 return {PointT{x0 + o, y0 + o}, {x1 + o, y0 + o}, {x1 + o, y1 + o}, {x0 + o, y1 + o}}; | |
| 45 } | |
| 46 | |
| 47 class ROI | |
| 48 { | |
| 49 public: | |
| 50 int x0, x1, y0, y1; | |
| 51 PerspectiveTransform mod2Pix; | |
| 52 }; | |
| 53 | |
| 54 using ROIs = std::vector<ROI>; | |
| 55 | |
| 56 DetectorResult SampleGrid(const BitMatrix& image, int width, int height, const ROIs& rois); | |
| 57 | |
| 58 } // ZXing |
