Difference between revisions of "Image Stitching for NVIDIA Jetson/User Guide/Controlling the Stitcher"

From RidgeRun Developer Connection
Jump to: navigation, search
(Usage Example)
(Usage Example)
Line 98: Line 98:
 
   stitcher. ! queue ! nvvidconv ! nvoverlaysink  
 
   stitcher. ! queue ! nvvidconv ! nvoverlaysink  
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
The indices of the stitcher's sinks (sink_'''0''', for example) maps directly to the image index we use in the homography list.
  
 
You can find more complex examples [[Image_Stitching_for_NVIDIA_Jetson/Examples|here]].
 
You can find more complex examples [[Image_Stitching_for_NVIDIA_Jetson/Examples|here]].

Revision as of 09:34, 10 March 2021



Previous: Image Stitching for NVIDIA Jetson Basics Index Next: User Guide/Homography estimation



Nvidia-preferred-partner-badge-rgb-for-screen.png



This page serves as a guide to configure the stitcher in order to meet different application requirements.

Homography List

The homography list is just a JSON file that defines the transformations and the relationships between the images. Here we will explore (by examples) how to create this file in order to stitch the corresponding images.

Case: 2 Images

2 Images Stitching Example

Let's assume we have only 2 images (with indices 0 an 1). These 2 images are related by a homography which can be computed using the Homography Estimation Guide. The computed homography transforms the Target image from the Reference image perspective.

This way, to fully describe a homography, we need to declare 3 parameters:

  • Matrix: the 3x3 transformation matrix.
  • Target: the index of the target image (i.e. the image to be transformed).
  • Reference: the index of the reference image (i.e. the image used as a reference to transform the target image).

Having this information, we build the Homography JSON file:

{
    "homographies":[
        {
            "images":{
                "target":1,
                "reference":0
            },
            "matrix":{
                "h00": 1, "h01": 0, "h02": 510,
                "h10": 0, "h11": 1, "h12": 0,
                "h20": 0, "h21": 0, "h22": 1
            }
        }
    ]
}


With this file we are describing a set of 2 images (0 and 1), where the given matrix will transform the image 1 based on 0.

Case: 3 Images

Error creating thumbnail: Unable to save thumbnail to destination

Similar to the 2 images case, we use homographies to relate the set of images. The rule is to use N-1 number of homographies, where N is the number of images.

One panoramic use case is to compute the homographies for both left (0) and right (2) images, using the center image (1) as the reference. The JSON file would look like this:

{
    "homographies":[
        {
            "images":{
                "target":0,
                "reference":1
            },
            "matrix":{
                "h00": 1, "h01": 0, "h02": -510,
                "h10": 0, "h11": 1, "h12": 0,
                "h20": 0, "h21": 0, "h22": 1
            }
        },
        {
            "images":{
                "target":2,
                "reference":1
            },
            "matrix":{
                "h00": 1, "h01": 0, "h02": 510,
                "h10": 0, "h11": 1, "h12": 0,
                "h20": 0, "h21": 0, "h22": 1
            }
        }
    ]
}

Blending

The stitcher has the capability of blending the limit between two adjacent images to hide the abrupt change of color and gain between the input images. The parameter to adjust this feature is called border-width, and is the number of pixels to blend.

Usage Example

The homography list is stored into the homographies.json file.

BORDER_WIDTH=10

gst-launch-1.0 -e cudastitcher name=stitcher \
  homography-list="`cat homographies.json | tr -d "\n" | tr -d " "`" \
  border-width=$BORDER_WIDTH \
  nvarguscamerasrc sensor-id=0 ! nvvidconv ! stitcher.sink_0 \
  nvarguscamerasrc sensor-id=1 ! nvvidconv ! stitcher.sink_1 \
  nvarguscamerasrc sensor-id=2 ! nvvidconv ! stitcher.sink_2 \
  stitcher. ! queue ! nvvidconv ! nvoverlaysink

The indices of the stitcher's sinks (sink_0, for example) maps directly to the image index we use in the homography list.

You can find more complex examples here.


Previous: Image Stitching for NVIDIA Jetson Basics Index Next: User Guide/Homography estimation