Replicating the behavior of cv2.warpPolar with nvdewarper plugin

Complete information of my setup.

• Hardware Platform (Jetson / GPU): NVIDIA GeForce RTX 2060
• DeepStream Version: 6.3
• NVIDIA GPU Driver Version (valid for GPU only): 535.183.01
• Issue Type( questions, new requirements, bugs): question
**• Using deepstream with python

Question 1:
I am trying to replicate the behavior of the function cv2.warpPolar using the nvdewarper plugin, but unable to do so. I have used different configs, and attached output images in each case. Please help. Also, if there is some other way to achieve this, please suggest it too, except building opencv with cuda support, that is a last resort.

Question 2:
Also, the config file uses camera intrinsic parameters like focal length, distortion params etc, is it possible to not use these i.e. similar to cv2.warpPolar? It is not always possible for me to calibrate using chess board images.


An example of cv2.warpPolar output, along with the used code:

Note: The image used here is the cropped screenshot of an example hikvision fisheye video from their youtube channel.

Here, we can see that the middle region is mapped to the bottom of the image, and the rest is unwrapped horizontally.

The used cv2 code:

def get_unwarped_image(fisheye_img_path, height_multiplier=1, width_multiplier=1):
    fisheye_img = cv2.imread(fisheye_img_path)
    height, width = fisheye_img.shape[:2]

    # Define output properties
    unwrap_width = width_multiplier*width
    unwrap_height = height_multiplier*height

    center = (width // 2, height // 2)
    max_radius = max(center)

    # Apply polar transformation
    unwrapped = cv2.warpPolar(fisheye_img, (unwrap_width, unwrap_height), center, max_radius, 
                              cv2.WARP_POLAR_LINEAR + cv2.INTER_LINEAR) 
    rotated = cv2.rotate(unwrapped, cv2.ROTATE_90_COUNTERCLOCKWISE)

    return rotated

Another example of unwarped image by the above code with different output dimensions:


The following shows the outputs of nvdewarper plugin along with used config files and their descriptions.

The video file used with the pipeline and the different config files are also attached to this post.

Test 1: Using the same config file that came with deepstream example app named config_dewarper_fish_dist_correction.txt but changed the projection type to 3 which is perspective-to-perspectve
Output:


Config file:
01_default_config_file_fish_dist_correction_with_projection_type_3_perspective_perspective.txt (2.3 KB)

Test 2: Using the same config file as above but changed projection type to 4 which is fish to perspective
Output:


Config file:
02_default_config_file_fish_dist_correction_with_projection_type_4_fish_perspective.txt (2.3 KB)

Tests 3 and 4: Using the same config file as above, but changed the output and input dimensions according to video used, and commented out camera calibration params like focal length, distortion.
Output: Blank image, leading to the assumption that if focal length and distortion are not given, the plugin gives blank image
Config files:
For test 3:
03_config_file_fish_dist_correction_with_projection_type_4_fish_perspective_changed_dimensions_centre_and_commented_calibration_params.txt (2.3 KB)
For test 4:
04_difference_from_03_is_output_dimensions_changed.txt (2.3 KB)

Test 5: Difference from test 3 is that camera calibration params are turned back on in the config file. The image looks like the following because of chosen output dimensions. See test 7 output for a better chosen output dimensions.
Output:


Config file:
05_difference_from_03_is_calibration_params_are_turned_back_on.txt (2.3 KB)

Test 6: The focal length in config file was commented out just to check while keeping distortion params, the result was blank image.

Test 7: The difference from test 5 is the output dimensions.
Output:


Config file:
07_difference_from_05_is_focal_length_is_switched_back_on_and_output_dimensions_made_same_as_04.txt (2.3 KB)

Two more tests were made with different output dimensions. But, they yielded similar results.

Test 10: Using another config file that came with deepstream example app named config_dewarper_perspective.txt but changed the projection type to 3 which is perspective-to-perspectve
Output:


Config file:
10_default_config_file_dewarper_perspective_with_projection_type_3_perspective_perspective.txt (1.8 KB)

Test 11: Using the same config file as test 10 but changing dimensions and center according to the video used similar to previous tests.
Output:


Config file:
11_difference_from_10_is_output_dimensions_and_center.txt (1.8 KB)


Here is the video file used in the pipeline:

Please help.

We currently do not have a similar API to implement the function cv2.warpPolar.

No. We still need some camera intrinsic parameters.

So what you need is to use your video as source and then output the effect of cv2.warpPolar, is that right?

Thanks for replying yuweiw.

yes, please. that’s the requirement.

Our dewarper plugin does not support this feature currently. You can use our nvdsvideotemplate plugin to implement your own needs. And use any algorithm in this plugin to process the video raw data to meet your needs.

1 Like