Stitcher is responsible with stitching provided images.
More...
|
None | __init__ (self, *, int target_image_mean=110, bool legacy_paste=False, float new_image_percentage=0.75, float min_homography_determinant=0.1, float filter_threshold=0.65, int max_iterations_before_fail=5, bool stitch_with_whole_image_on_fail=True, int initial_random_point_count=16, float ransac_threshold=0.5, initial_ransac_iterations=1250, ransac_steps=500) |
| Creates a Stitcher object.
|
|
bool | stitch (self, np.ndarray image, bool whole_image=False) |
| Stitches the given image to the full_image.
|
|
|
ImageHistory | history |
|
Optional[np.ndarray] | full_image |
|
int | target_image_mean |
|
bool | legacy_paste |
|
float | new_image_percentage |
|
float | min_homography_determinant |
|
float | filter_threshold |
|
bool | stitch_with_whole_image_on_fail |
|
int | max_iterations_before_fail |
|
int | initial_random_point_count |
|
float | ransac_threshold |
|
int | initial_ransac_iterations |
|
int | ransac_steps |
|
cv2.FlannBasedMatcher | flann_matcher |
|
cv2.BFMatcher | bf_matcher |
|
cv2.SIFT | sift_extractor |
|
| history |
|
| full_image |
|
| ransac_threshold |
|
|
np.ndarray | __preprocess_image (self, np.ndarray image) |
| Preprocesses the given image.
|
|
Tuple[int, int] | __paste_image (self, np.ndarray image, int x_offset=0, int y_offset=0, bool whole_image=False) |
| Pastes the image to the full_image.
|
|
KDTuple | __detect_and_compute (self, np.ndarray image) |
| Detect and compute keypoints and descriptors of given image using SIFT.
|
|
Stitcher is responsible with stitching provided images.
Stitching process goes like this:
- If the provided image is the first image, set self.image to that image and stop
- Otherwise, take the current image with last image and calculate the homography matrix between the images and applies it to the current image. Also calculates the where that image should be positioned in the final image.
- To paste the image, stitcher first creates a new canvas and pastes the old image and the warped image to the correct position. There are two blending modes: legacy mode and the new mode. Legacy mode is just alpha blending. The new mode however, mixes the overlapping parts of two images by a predefined constant.
◆ __init__()
None stitcher.Stitcher.__init__ |
( |
| self, |
|
|
* | , |
|
|
int | target_image_mean = 110, |
|
|
bool | legacy_paste = False, |
|
|
float | new_image_percentage = 0.75, |
|
|
float | min_homography_determinant = 0.1, |
|
|
float | filter_threshold = 0.65, |
|
|
int | max_iterations_before_fail = 5, |
|
|
bool | stitch_with_whole_image_on_fail = True, |
|
|
int | initial_random_point_count = 16, |
|
|
float | ransac_threshold = 0.5, |
|
|
| initial_ransac_iterations = 1250, |
|
|
| ransac_steps = 500 ) |
Creates a Stitcher object.
- Parameters
-
target_image_mean | The target brightness value of input images |
legacy_paste | Turn on legacy paste mode. The difference between legacy paste and new paste modes are explained in the class description. |
new_image_percentage | Used when mixing two images in the new paste mode. Does a linear interpolation between the pixels of the old image and the new image. Essentially c*new + (1-c)*old where c is this constant. |
min_homography_determinant | Minimum allowed value for the determinant of the homography matrix. |
filter_threshold | A threshold value used to filter in the Util.match function. |
max_iterations_before_fail | If a step fails, instead of erroring out, the stitcher tries stitching again with different values until a match is found. This is the number of tries before failure. |
stitch_with_whole_image_on_fail | If stitcher fails to stitch and image with its predecessor image and this option is enabled, it tries to stitch it with the whole image and starts the whole process again. |
initial_random_point_count | The ransac works by picking some random points and checking if they are "good". On each fail the stitcher decreases this value by
- However, the minimum point count is 4.
|
ransac_threshold | A threshold value to determine if a point is "good" in the ransac algorithm |
initial_ransac_iterations | The initial iteration count for ransac |
ransac_steps | After each failure, the iteration count increases by this value |
◆ __detect_and_compute()
KDTuple stitcher.Stitcher.__detect_and_compute |
( |
| self, |
|
|
np.ndarray | image ) |
|
private |
Detect and compute keypoints and descriptors of given image using SIFT.
- Parameters
-
image | Image to find keypoints and descriptors |
- Returns
- Keypoints and descriptors as a KDTuple object
◆ __paste_image()
Tuple[int, int] stitcher.Stitcher.__paste_image |
( |
| self, |
|
|
np.ndarray | image, |
|
|
int | x_offset = 0, |
|
|
int | y_offset = 0, |
|
|
bool | whole_image = False ) |
|
private |
Pastes the image to the full_image.
- Parameters
-
image | Image to be pasted |
x_offset | Horizontal offset from the last pasted image |
y_offset | Vertical offset from the last pasted image |
whole_image | If set to true, the offset applies to the whole image, not to the last pasted image |
- Returns
- The total offset of the image as a tuple of ints
◆ __preprocess_image()
np.ndarray stitcher.Stitcher.__preprocess_image |
( |
| self, |
|
|
np.ndarray | image ) |
|
private |
Preprocesses the given image.
Converts it from BGR to BGRA and applies a mean shift to shift the mean of the image to the target_brightness parameter
- Parameters
-
- Returns
- Preprocessed image
◆ stitch()
bool stitcher.Stitcher.stitch |
( |
| self, |
|
|
np.ndarray | image, |
|
|
bool | whole_image = False ) |
Stitches the given image to the full_image.
The process is explained in the class description.
- Parameters
-
image | Image to stitch |
whole_image | If set to true, it uses full_image instead of the last stitched image for stitching |
- Returns
- True if stitching was successful, False otherwise
The documentation for this class was generated from the following file: