src.panorama package¶
Submodules¶
src.panorama.panorama module¶
- class src.panorama.panorama.ImagePanorama(images)¶
Bases:
PyQt5.QtWidgets.QDialog,src.panorama.panorama_ui.ImagePanoramaUIThe ImagePanorama class represents stitching between chosen images.
- ERROR_MESSAGES = {1: "Need more input images to construct the panorama,\nor try to reverse the image order on the right list\nusing the 'Up' and 'Down' buttons", 2: "RANSAC homography estimation failed:\nYou may need more images or your images don't have enough distinguishing,\nunique texture/objects for keypoints to be accurately matched", 3: 'Failed to properly estimate camera intrinsics/extrinsics from the input images', 4: 'The Manual mode stitches only two images'}¶
- static crop_borders(stitched)¶
Cut out black borders from stitched images.
- Parameters
stitched (numpy.ndarray) – The stitched images
- Returns
The cropped panorama (ROI)
- Return type
numpy.ndarray
- get_selected_images()¶
Return image data from the list on the right side.
- show_description()¶
- stitch_default(images_data)¶
Stitch images with built-in OpenCV .stitch() method.
- Parameters
images_data (list) – The images to stitch
- Returns
The status of stitching and image panorama
- Return type
tuple
- stitch_images()¶
Stitch selected images to the panorama.
- There are two stitch modes:
Default: use built-in OpenCV .stitch() method.
Manual: own implementation, input image order sensitive; see
Stitcherfor more information.
Additionally, there is a crop feature, which cuts out black borders.
- Photos with the poor matching area can have some problems:
For Default mode, the order of input images sometimes is sensitive.
For Default mode, sometimes you will get a little bit different output, which can cause program errors.
Noticed that the built-in OpenCV mode has some problems with stitching the same images several times.
- stitch_manually(images_data)¶
Stitch two images using manual implementation, input image order sensitive.
See
Stitcherfor more information.- Parameters
images_data (list) – The two images to stitch
- Returns
The status of stitching and image panorama
- Return type
tuple
- src.panorama.panorama.Stitcher_create([mode]) → retval¶
. @brief Creates a Stitcher configured in one of the stitching modes. . . @param mode Scenario for stitcher operation. This is usually determined by source of images . to stitch and their transformation. Default parameters will be chosen for operation in given . scenario. . @return Stitcher class instance.
- src.panorama.panorama.boundingRect(array) → retval¶
. @brief Calculates the up-right bounding rectangle of a point set or non-zero pixels of gray-scale image. . . The function calculates and returns the minimal up-right bounding rectangle for the specified point set or . non-zero pixels of gray-scale image. . . @param array Input gray-scale image or 2D point set, stored in std::vector or Mat.
- src.panorama.panorama.contourArea(contour[, oriented]) → retval¶
. @brief Calculates a contour area. . . The function computes a contour area. Similarly to moments , the area is computed using the Green . formula. Thus, the returned area and the number of non-zero pixels, if you draw the contour using . #drawContours or #fillPoly , can be different. Also, the function will most certainly give a wrong . results for contours with self-intersections. . . Example: . @code . vector<Point> contour; . contour.push_back(Point2f(0, 0)); . contour.push_back(Point2f(10, 0)); . contour.push_back(Point2f(10, 10)); . contour.push_back(Point2f(5, 4)); . . double area0 = contourArea(contour); . vector<Point> approx; . approxPolyDP(contour, approx, 5, true); . double area1 = contourArea(approx); . . cout << “area0 =” << area0 << endl << . “area1 =” << area1 << endl << . “approx poly vertices” << approx.size() << endl; . @endcode . @param contour Input vector of 2D points (contour vertices), stored in std::vector or Mat. . @param oriented Oriented area flag. If it is true, the function returns a signed area value, . depending on the contour orientation (clockwise or counter-clockwise). Using this feature you can . determine orientation of a contour by taking the sign of an area. By default, the parameter is . false, which means that the absolute value is returned.
- src.panorama.panorama.copyMakeBorder(src, top, bottom, left, right, borderType[, dst[, value]]) → dst¶
. @brief Forms a border around an image. . . The function copies the source image into the middle of the destination image. The areas to the . left, to the right, above and below the copied source image will be filled with extrapolated . pixels. This is not what filtering functions based on it do (they extrapolate pixels on-fly), but . what other more complex functions, including your own, may do to simplify image boundary handling. . . The function supports the mode when src is already in the middle of dst . In this case, the . function does not copy src itself but simply constructs the border, for example: . . @code{.cpp} . // let border be the same in all directions . int border=2; . // constructs a larger image to fit both the image and the border . Mat gray_buf(rgb.rows + border*2, rgb.cols + border*2, rgb.depth()); . // select the middle part of it w/o copying data . Mat gray(gray_canvas, Rect(border, border, rgb.cols, rgb.rows)); . // convert image from RGB to grayscale . cvtColor(rgb, gray, COLOR_RGB2GRAY); . // form a border in-place . copyMakeBorder(gray, gray_buf, border, border, . border, border, BORDER_REPLICATE); . // now do some custom filtering … . … . @endcode . @note When the source image is a part (ROI) of a bigger image, the function will try to use the . pixels outside of the ROI to form a border. To disable this feature and always do extrapolation, as . if src was not a ROI, use borderType | #BORDER_ISOLATED. . . @param src Source image. . @param dst Destination image of the same type as src and the size Size(src.cols+left+right, . src.rows+top+bottom) . . @param top the top pixels . @param bottom the bottom pixels . @param left the left pixels . @param right Parameter specifying how many pixels in each direction from the source image rectangle . to extrapolate. For example, top=1, bottom=1, left=1, right=1 mean that 1 pixel-wide border needs . to be built. . @param borderType Border type. See borderInterpolate for details. . @param value Border value if borderType==BORDER_CONSTANT . . . @sa borderInterpolate
- src.panorama.panorama.countNonZero(src) → retval¶
. @brief Counts non-zero array elements. . . The function returns the number of non-zero elements in src : . f[sum _{I: ; texttt{src} (I) ne0 } 1f] . @param src single-channel array. . @sa mean, meanStdDev, norm, minMaxLoc, calcCovarMatrix
- src.panorama.panorama.cvtColor(src, code[, dst[, dstCn]]) → dst¶
. @brief Converts an image from one color space to another. . . The function converts an input image from one color space to another. In case of a transformation . to-from RGB color space, the order of the channels should be specified explicitly (RGB or BGR). Note . that the default color format in OpenCV is often referred to as RGB but it is actually BGR (the . bytes are reversed). So the first byte in a standard (24-bit) color image will be an 8-bit Blue . component, the second byte will be Green, and the third byte will be Red. The fourth, fifth, and . sixth bytes would then be the second pixel (Blue, then Green, then Red), and so on. . . The conventional ranges for R, G, and B channel values are: . - 0 to 255 for CV_8U images . - 0 to 65535 for CV_16U images . - 0 to 1 for CV_32F images . . In case of linear transformations, the range does not matter. But in case of a non-linear . transformation, an input RGB image should be normalized to the proper value range to get the correct . results, for example, for RGB f$rightarrowf$ L*u*v* transformation. For example, if you have a . 32-bit floating-point image directly converted from an 8-bit image without any scaling, then it will . have the 0..255 value range instead of 0..1 assumed by the function. So, before calling #cvtColor , . you need first to scale the image down: . @code . img *= 1./255; . cvtColor(img, img, COLOR_BGR2Luv); . @endcode . If you use #cvtColor with 8-bit images, the conversion will have some information lost. For many . applications, this will not be noticeable but it is recommended to use 32-bit images in applications . that need the full range of colors or that convert an image before an operation and then convert . back. . . If conversion adds the alpha channel, its value will set to the maximum of corresponding channel . range: 255 for CV_8U, 65535 for CV_16U, 1 for CV_32F. . . @param src input image: 8-bit unsigned, 16-bit unsigned ( CV_16UC… ), or single-precision . floating-point. . @param dst output image of the same size and depth as src. . @param code color space conversion code (see #ColorConversionCodes). . @param dstCn number of channels in the destination image; if the parameter is 0, the number of the . channels is derived automatically from src and code. . . @see @ref imgproc_color_conversions
- src.panorama.panorama.erode(src, kernel[, dst[, anchor[, iterations[, borderType[, borderValue]]]]]) → dst¶
. @brief Erodes an image by using a specific structuring element. . . The function erodes the source image using the specified structuring element that determines the . shape of a pixel neighborhood over which the minimum is taken: . . f[texttt{dst} (x,y) = min _{(x’,y’): , texttt{element} (x’,y’) ne0 } texttt{src} (x+x’,y+y’)f] . . The function supports the in-place mode. Erosion can be applied several ( iterations ) times. In . case of multi-channel images, each channel is processed independently. . . @param src input image; the number of channels can be arbitrary, but the depth should be one of . CV_8U, CV_16U, CV_16S, CV_32F or CV_64F. . @param dst output image of the same size and type as src. . @param kernel structuring element used for erosion; if element=Mat(), a 3 x 3 rectangular . structuring element is used. Kernel can be created using #getStructuringElement. . @param anchor position of the anchor within the element; default value (-1, -1) means that the . anchor is at the element center. . @param iterations number of times erosion is applied. . @param borderType pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. . @param borderValue border value in case of a constant border . @sa dilate, morphologyEx, getStructuringElement
- src.panorama.panorama.findContours(image, mode, method[, contours[, hierarchy[, offset]]]) → contours, hierarchy¶
. @brief Finds contours in a binary image. . . The function retrieves contours from the binary image using the algorithm @cite Suzuki85 . The contours . are a useful tool for shape analysis and object detection and recognition. See squares.cpp in the . OpenCV sample directory. . @note Since opencv 3.2 source image is not modified by this function. . . @param image Source, an 8-bit single-channel image. Non-zero pixels are treated as 1’s. Zero . pixels remain 0’s, so the image is treated as binary . You can use #compare, #inRange, #threshold , . #adaptiveThreshold, #Canny, and others to create a binary image out of a grayscale or color one. . If mode equals to #RETR_CCOMP or #RETR_FLOODFILL, the input can also be a 32-bit integer image of labels (CV_32SC1). . @param contours Detected contours. Each contour is stored as a vector of points (e.g. . std::vector<std::vector<cv::Point> >). . @param hierarchy Optional output vector (e.g. std::vector<cv::Vec4i>), containing information about the image topology. It has . as many elements as the number of contours. For each i-th contour contours[i], the elements . hierarchy[i][0] , hierarchy[i][1] , hierarchy[i][2] , and hierarchy[i][3] are set to 0-based indices . in contours of the next and previous contours at the same hierarchical level, the first child . contour and the parent contour, respectively. If for the contour i there are no next, previous, . parent, or nested contours, the corresponding elements of hierarchy[i] will be negative. . @param mode Contour retrieval mode, see #RetrievalModes . @param method Contour approximation method, see #ContourApproximationModes . @param offset Optional offset by which every contour point is shifted. This is useful if the . contours are extracted from the image ROI and then they should be analyzed in the whole image . context.
- src.panorama.panorama.rectangle(img, pt1, pt2, color[, thickness[, lineType[, shift]]]) → img¶
. @brief Draws a simple, thick, or filled up-right rectangle. . . The function cv::rectangle draws a rectangle outline or a filled rectangle whose two opposite corners . are pt1 and pt2. . . @param img Image. . @param pt1 Vertex of the rectangle. . @param pt2 Vertex of the rectangle opposite to pt1 . . @param color Rectangle color or brightness (grayscale image). . @param thickness Thickness of lines that make up the rectangle. Negative values, like #FILLED, . mean that the function has to draw a filled rectangle. . @param lineType Type of the line. See #LineTypes . @param shift Number of fractional bits in the point coordinates.
rectangle(img, rec, color[, thickness[, lineType[, shift]]]) -> img . @overload . . use rec parameter as alternative specification of the drawn rectangle: r.tl() and . r.br()-Point(1,1) are opposite corners
- src.panorama.panorama.subtract(src1, src2[, dst[, mask[, dtype]]]) → dst¶
. @brief Calculates the per-element difference between two arrays or array and a scalar. . . The function subtract calculates: . - Difference between two arrays, when both input arrays have the same size and the same number of . channels: . f[texttt{dst}(I) = texttt{saturate} ( texttt{src1}(I) - texttt{src2}(I)) quad texttt{if mask}(I) ne0f] . - Difference between an array and a scalar, when src2 is constructed from Scalar or has the same . number of elements as src1.channels(): . f[texttt{dst}(I) = texttt{saturate} ( texttt{src1}(I) - texttt{src2} ) quad texttt{if mask}(I) ne0f] . - Difference between a scalar and an array, when src1 is constructed from Scalar or has the same . number of elements as src2.channels(): . f[texttt{dst}(I) = texttt{saturate} ( texttt{src1} - texttt{src2}(I) ) quad texttt{if mask}(I) ne0f] . - The reverse difference between a scalar and an array in the case of SubRS: . f[texttt{dst}(I) = texttt{saturate} ( texttt{src2} - texttt{src1}(I) ) quad texttt{if mask}(I) ne0f] . where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each . channel is processed independently. . . The first function in the list above can be replaced with matrix expressions: . @code{.cpp} . dst = src1 - src2; . dst -= src1; // equivalent to subtract(dst, src1, dst); . @endcode . The input arrays and the output array can all have the same or different depths. For example, you . can subtract to 8-bit unsigned arrays and store the difference in a 16-bit signed array. Depth of . the output array is determined by dtype parameter. In the second and third cases above, as well as . in the first case, when src1.depth() == src2.depth(), dtype can be set to the default -1. In this . case the output array will have the same depth as the input array, be it src1, src2 or both. . @note Saturation is not applied when the output array has the depth CV_32S. You may even get . result of an incorrect sign in the case of overflow. . @param src1 first input array or a scalar. . @param src2 second input array or a scalar. . @param dst output array of the same size and the same number of channels as the input array. . @param mask optional operation mask; this is an 8-bit single channel array that specifies elements . of the output array to be changed. . @param dtype optional depth of the output array . @sa add, addWeighted, scaleAdd, Mat::convertTo
- src.panorama.panorama.threshold(src, thresh, maxval, type[, dst]) → retval, dst¶
. @brief Applies a fixed-level threshold to each array element. . . The function applies fixed-level thresholding to a multiple-channel array. The function is typically . used to get a bi-level (binary) image out of a grayscale image ( #compare could be also used for . this purpose) or for removing a noise, that is, filtering out pixels with too small or too large . values. There are several types of thresholding supported by the function. They are determined by . type parameter. . . Also, the special values #THRESH_OTSU or #THRESH_TRIANGLE may be combined with one of the . above values. In these cases, the function determines the optimal threshold value using the Otsu’s . or Triangle algorithm and uses it instead of the specified thresh. . . @note Currently, the Otsu’s and Triangle methods are implemented only for 8-bit single-channel images. . . @param src input array (multiple-channel, 8-bit or 32-bit floating point). . @param dst output array of the same size and type and the same number of channels as src. . @param thresh threshold value. . @param maxval maximum value to use with the #THRESH_BINARY and #THRESH_BINARY_INV thresholding . types. . @param type thresholding type (see #ThresholdTypes). . @return the computed threshold value if Otsu’s or Triangle methods used. . . @sa adaptiveThreshold, findContours, compare, min, max
src.panorama.panorama_ui module¶
- class src.panorama.panorama_ui.ImagePanoramaUI¶
Bases:
src.operations.form_ui.FormUIBuild UI for
panorama.ImagePanorama.- button_add_all_clicked()¶
Move all items from the left list to the right.
- button_add_clicked()¶
Move a selected item from the left list to the right.
- button_down_clicked()¶
Move a selected item from the right list to the bottom.
- button_remove_all_clicked()¶
Move all items from the right list to the left.
- button_remove_clicked()¶
Move a selected item from the right list to the left.
- button_up_clicked()¶
Move a selected item from the right list to the top.
- init_ui(panorama)¶
Create user interface for
panorama.ImagePanorama.The method creates the widget objects in the proper containers and assigns the object names to them.
- Parameters
panorama (
panorama.ImagePanorama) – The image panorama dialog
- set_widget_connections()¶
Connect widgets to methods.
- update_button_status()¶
Update buttons access whenever move items.
src.panorama.stitcher module¶
- src.panorama.stitcher.BFMatcher_create([normType[, crossCheck]]) → retval¶
. @brief Brute-force matcher create method. . @param normType One of NORM_L1, NORM_L2, NORM_HAMMING, NORM_HAMMING2. L1 and L2 norms are . preferable choices for SIFT and SURF descriptors, NORM_HAMMING should be used with ORB, BRISK and . BRIEF, NORM_HAMMING2 should be used with ORB when WTA_K==3 or 4 (see ORB::ORB constructor . description). . @param crossCheck If it is false, this is will be default BFMatcher behaviour when it finds the k . nearest neighbors for each query descriptor. If crossCheck==true, then the knnMatch() method with . k=1 will only return pairs (i,j) such that for i-th query descriptor the j-th descriptor in the . matcher’s collection is the nearest and vice versa, i.e. the BFMatcher will only return consistent . pairs. Such technique usually produces best results with minimal number of outliers when there are . enough matches. This is alternative to the ratio test, used by D. Lowe in SIFT paper.
- src.panorama.stitcher.ORB_create([nfeatures[, scaleFactor[, nlevels[, edgeThreshold[, firstLevel[, WTA_K[, scoreType[, patchSize[, fastThreshold]]]]]]]]]) → retval¶
. @brief The ORB constructor . . @param nfeatures The maximum number of features to retain. . @param scaleFactor Pyramid decimation ratio, greater than 1. scaleFactor==2 means the classical . pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor . will degrade feature matching scores dramatically. On the other hand, too close to 1 scale factor . will mean that to cover certain scale range you will need more pyramid levels and so the speed . will suffer. . @param nlevels The number of pyramid levels. The smallest level will have linear size equal to . input_image_linear_size/pow(scaleFactor, nlevels - firstLevel). . @param edgeThreshold This is size of the border where the features are not detected. It should . roughly match the patchSize parameter. . @param firstLevel The level of pyramid to put source image to. Previous layers are filled . with upscaled source image. . @param WTA_K The number of points that produce each element of the oriented BRIEF descriptor. The . default value 2 means the BRIEF where we take a random point pair and compare their brightnesses, . so we get 0/1 response. Other possible values are 3 and 4. For example, 3 means that we take 3 . random points (of course, those point coordinates are random, but they are generated from the . pre-defined seed, so each element of BRIEF descriptor is computed deterministically from the pixel . rectangle), find point of maximum brightness and output index of the winner (0, 1 or 2). Such . output will occupy 2 bits, and therefore it will need a special variant of Hamming distance, . denoted as NORM_HAMMING2 (2 bits per bin). When WTA_K=4, we take 4 random points to compute each . bin (that will also occupy 2 bits with possible values 0, 1, 2 or 3). . @param scoreType The default HARRIS_SCORE means that Harris algorithm is used to rank features . (the score is written to KeyPoint::score and is used to retain best nfeatures features); . FAST_SCORE is alternative value of the parameter that produces slightly less stable keypoints, . but it is a little faster to compute. . @param patchSize size of the patch used by the oriented BRIEF descriptor. Of course, on smaller . pyramid layers the perceived image area covered by a feature will be larger. . @param fastThreshold the fast threshold
- class src.panorama.stitcher.Stitcher(images, nfeatures, details=False)¶
Bases:
objectThe Stitcher class implements manual stitching between two images.
- Panorama (stitch) algorithm:
Detect keypoints and descriptors.
Detect a set of matching points that is present in both images (overlapping area).
Apply the RANSAC method to improve the matching process detection.
Apply perspective transformation on the first image using the second image as a reference frame.
Stitch images together.
- MIN_MATCH_COUNT = 10¶
- REPROJ_THRESH = 5.0¶
- detect_keypoints()¶
Detect keypoints and descriptors.
- match_keypoints()¶
Match keypoints (features) between two images.
- stitch()¶
Perform all the stitching algorithm.
Detect keypoints using
detect_keypoints().Match keypoints using
match_keypoints().Make sure we found at least the minimum number of matches defined in
MIN_MATCH_COUNT.Calculate homography 3x3 matrix using RANSAC procedure.
Stitch images using
warp_images().
- static warp_images(image1, image2, H)¶
Warp perspective for the first image and stitch it with the referenced second image.
- Parameters
image1 (numpy.ndarray) – The first image to warp perspective
image2 (numpy.ndarray) – The second image as the reference
H (numpy.ndarray) – The homography 3x3 matrix
- Returns
The stitched image
- Return type
numpy.ndarray
- src.panorama.stitcher.drawKeypoints(image, keypoints, outImage[, color[, flags]]) → outImage¶
. @brief Draws keypoints. . . @param image Source image. . @param keypoints Keypoints from the source image. . @param outImage Output image. Its content depends on the flags value defining what is drawn in the . output image. See possible flags bit values below. . @param color Color of keypoints. . @param flags Flags setting drawing features. Possible flags bit values are defined by . DrawMatchesFlags. See details above in drawMatches . . . @note . For Python API, flags are modified as cv.DRAW_MATCHES_FLAGS_DEFAULT, . cv.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS, cv.DRAW_MATCHES_FLAGS_DRAW_OVER_OUTIMG, . cv.DRAW_MATCHES_FLAGS_NOT_DRAW_SINGLE_POINTS
- src.panorama.stitcher.findHomography(srcPoints, dstPoints[, method[, ransacReprojThreshold[, mask[, maxIters[, confidence]]]]]) → retval, mask¶
. @brief Finds a perspective transformation between two planes. . . @param srcPoints Coordinates of the points in the original plane, a matrix of the type CV_32FC2 . or vector<Point2f> . . @param dstPoints Coordinates of the points in the target plane, a matrix of the type CV_32FC2 or . a vector<Point2f> . . @param method Method used to compute a homography matrix. The following methods are possible: . - 0 - a regular method using all the points, i.e., the least squares method . - @ref RANSAC - RANSAC-based robust method . - @ref LMEDS - Least-Median robust method . - @ref RHO - PROSAC-based robust method . @param ransacReprojThreshold Maximum allowed reprojection error to treat a point pair as an inlier . (used in the RANSAC and RHO methods only). That is, if . f[| texttt{dstPoints} _i - texttt{convertPointsHomogeneous} ( texttt{H} * texttt{srcPoints} _i) |_2 > texttt{ransacReprojThreshold}f] . then the point f$if$ is considered as an outlier. If srcPoints and dstPoints are measured in pixels, . it usually makes sense to set this parameter somewhere in the range of 1 to 10. . @param mask Optional output mask set by a robust method ( RANSAC or LMeDS ). Note that the input . mask values are ignored. . @param maxIters The maximum number of RANSAC iterations. . @param confidence Confidence level, between 0 and 1. . . The function finds and returns the perspective transformation f$Hf$ between the source and the . destination planes: . . f[s_i vecthree{x’_i}{y’_i}{1} sim H vecthree{x_i}{y_i}{1}f] . . so that the back-projection error . . f[sum _i left ( x’_i- frac{h_{11} x_i + h_{12} y_i + h_{13}}{h_{31} x_i + h_{32} y_i + h_{33}} right )^2+ left ( y’_i- frac{h_{21} x_i + h_{22} y_i + h_{23}}{h_{31} x_i + h_{32} y_i + h_{33}} right )^2f] . . is minimized. If the parameter method is set to the default value 0, the function uses all the point . pairs to compute an initial homography estimate with a simple least-squares scheme. . . However, if not all of the point pairs ( f$srcPoints_if$, f$dstPoints_if$ ) fit the rigid perspective . transformation (that is, there are some outliers), this initial estimate will be poor. In this case, . you can use one of the three robust methods. The methods RANSAC, LMeDS and RHO try many different . random subsets of the corresponding point pairs (of four pairs each, collinear pairs are discarded), estimate the homography matrix . using this subset and a simple least-squares algorithm, and then compute the quality/goodness of the . computed homography (which is the number of inliers for RANSAC or the least median re-projection error for . LMeDS). The best subset is then used to produce the initial estimate of the homography matrix and . the mask of inliers/outliers. . . Regardless of the method, robust or not, the computed homography matrix is refined further (using . inliers only in case of a robust method) with the Levenberg-Marquardt method to reduce the . re-projection error even more. . . The methods RANSAC and RHO can handle practically any ratio of outliers but need a threshold to . distinguish inliers from outliers. The method LMeDS does not need any threshold but it works . correctly only when there are more than 50% of inliers. Finally, if there are no outliers and the . noise is rather small, use the default method (method=0). . . The function is used to find initial intrinsic and extrinsic matrices. Homography matrix is . determined up to a scale. Thus, it is normalized so that f$h_{33}=1f$. Note that whenever an f$Hf$ matrix . cannot be estimated, an empty one will be returned. . . @sa . getAffineTransform, estimateAffine2D, estimateAffinePartial2D, getPerspectiveTransform, warpPerspective, . perspectiveTransform
findHomography(srcPoints, dstPoints, params[, mask]) -> retval, mask . @overload
- src.panorama.stitcher.imshow(winname, mat) → None¶
. @brief Displays an image in the specified window. . . The function imshow displays an image in the specified window. If the window was created with the . cv::WINDOW_AUTOSIZE flag, the image is shown with its original size, however it is still limited by the screen resolution. . Otherwise, the image is scaled to fit the window. The function may scale the image, depending on its depth: . . - If the image is 8-bit unsigned, it is displayed as is. . - If the image is 16-bit unsigned or 32-bit integer, the pixels are divided by 256. That is, the . value range [0,255*256] is mapped to [0,255]. . - If the image is 32-bit or 64-bit floating-point, the pixel values are multiplied by 255. That is, the . value range [0,1] is mapped to [0,255]. . . If window was created with OpenGL support, cv::imshow also support ogl::Buffer , ogl::Texture2D and . cuda::GpuMat as input. . . If the window was not created before this function, it is assumed creating a window with cv::WINDOW_AUTOSIZE. . . If you need to show an image that is bigger than the screen resolution, you will need to call namedWindow(“”, WINDOW_NORMAL) before the imshow. . . @note This function should be followed by cv::waitKey function which displays the image for specified . milliseconds. Otherwise, it won’t display the image. For example, waitKey(0) will display the window . infinitely until any keypress (it is suitable for image display). waitKey(25) will display a frame . for 25 ms, after which display will be automatically closed. (If you put it in a loop to read . videos, it will display the video frame-by-frame) . . @note . . [__Windows Backend Only__] Pressing Ctrl+C will copy the image to the clipboard. . . [__Windows Backend Only__] Pressing Ctrl+S will show a dialog to save the image. . . @param winname Name of the window. . @param mat Image to be shown.
- src.panorama.stitcher.perspectiveTransform(src, m[, dst]) → dst¶
. @brief Performs the perspective matrix transformation of vectors. . . The function cv::perspectiveTransform transforms every element of src by . treating it as a 2D or 3D vector, in the following way: . f[(x, y, z) rightarrow (x’/w, y’/w, z’/w)f] . where . f[(x’, y’, z’, w’) = texttt{mat} cdot begin{bmatrix} x & y & z & 1 end{bmatrix}f] . and . f[w = fork{w’}{if (w’ ne 0)}{infty}{otherwise}f] . . Here a 3D vector transformation is shown. In case of a 2D vector . transformation, the z component is omitted. . . @note The function transforms a sparse set of 2D or 3D vectors. If you . want to transform an image using perspective transformation, use . warpPerspective . If you have an inverse problem, that is, you want to . compute the most probable perspective transformation out of several . pairs of corresponding points, you can use getPerspectiveTransform or . findHomography . . @param src input two-channel or three-channel floating-point array; each . element is a 2D/3D vector to be transformed. . @param dst output array of the same size and type as src. . @param m 3x3 or 4x4 floating-point transformation matrix. . @sa transform, warpPerspective, getPerspectiveTransform, findHomography
- src.panorama.stitcher.waitKey([delay]) → retval¶
. @brief Waits for a pressed key. . . The function waitKey waits for a key event infinitely (when f$texttt{delay}leq 0f$ ) or for delay . milliseconds, when it is positive. Since the OS has a minimum time between switching threads, the . function will not wait exactly delay ms, it will wait at least delay ms, depending on what else is . running on your computer at that time. It returns the code of the pressed key or -1 if no key was . pressed before the specified time had elapsed. . . @note . . This function is the only method in HighGUI that can fetch and handle events, so it needs to be . called periodically for normal event processing unless HighGUI is used within an environment that . takes care of event processing. . . @note . . The function only works if there is at least one HighGUI window created and the window is active. . If there are several HighGUI windows, any of them can be active. . . @param delay Delay in milliseconds. 0 is the special value that means “forever”.
- src.panorama.stitcher.warpPerspective(src, M, dsize[, dst[, flags[, borderMode[, borderValue]]]]) → dst¶
. @brief Applies a perspective transformation to an image. . . The function warpPerspective transforms the source image using the specified matrix: . . f[texttt{dst} (x,y) = texttt{src} left ( frac{M_{11} x + M_{12} y + M_{13}}{M_{31} x + M_{32} y + M_{33}} , . frac{M_{21} x + M_{22} y + M_{23}}{M_{31} x + M_{32} y + M_{33}} right )f] . . when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with invert . and then put in the formula above instead of M. The function cannot operate in-place. . . @param src input image. . @param dst output image that has the size dsize and the same type as src . . @param M f$3times 3f$ transformation matrix. . @param dsize size of the output image. . @param flags combination of interpolation methods (#INTER_LINEAR or #INTER_NEAREST) and the . optional flag #WARP_INVERSE_MAP, that sets M as the inverse transformation ( . f$texttt{dst}rightarrowtexttt{src}f$ ). . @param borderMode pixel extrapolation method (#BORDER_CONSTANT or #BORDER_REPLICATE). . @param borderValue value used in case of a constant border; by default, it equals 0. . . @sa warpAffine, resize, remap, getRectSubPix, perspectiveTransform