# How to use OpenCV LensDistortion Plugin?

**URL:** <https://forums.unrealengine.com/t/how-to-use-opencv-lensdistortion-plugin/476209>\
**Category:** Plugins\
**Tags:** opencv, unreal-engine, Plugins, question\
**Created:** [December 24, 2020, 3:27pm UTC](https://forums.unrealengine.com/t/how-to-use-opencv-lensdistortion-plugin/476209 "2020-12-24T15:27:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_c17aad921](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_c17aad921](https://forums.unrealengine.com/u/anonymous_user_c17aad921)\
**Post date:** [December 24, 2020, 3:27pm UTC](https://forums.unrealengine.com/t/how-to-use-opencv-lensdistortion-plugin/476209/1 "2020-12-24T15:27:23Z")

</div>

I am beginner to UE4.

I’m currently trying to simulate my own fisheye camera within UE4. I’m thinking of creating my own fisheye camera model since it doesn’t seem to be officially supported.

I’m thinking that I can use the OpenCV LensDistortion plugin to create a fisheye camera by setting the camera parameters on my own.

I have the following settings in the camera actor, but what am I missing?

If you know, please advise me.

 ![325295-screenshot-from-2020-12-21-15-48-12.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/6/2/162f5c3f15b14440ae4f93b8e57150cf4dfc1158.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2bf6072d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2bf6072d](https://forums.unrealengine.com/u/anonymous_user_2bf6072d)\
**Post date:** [December 30, 2020, 10:26pm UTC](https://forums.unrealengine.com/t/how-to-use-opencv-lensdistortion-plugin/476209/2 "2020-12-30T22:26:48Z")

</div>

First I created a Render Target to store the output of the Undistort Displacement Map.

I then fed the return value from the _Create Undistort UVDisplacement Map_ to the _Draw Displacement Map to Render Target_ function where my Render Target is specified.

 ![325954-screenshot-2020-12-30-152421.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/e/8/ce8dc2e56711b900254f4af61d7567c873f5f749.png)

You can then assign the Render Target to _Texture Sample_ node in a Material Blueprint as per below. Since the _Distort to Undistort_ values are in the R and G channels, I’ve applied a mask to filter out the other values. Finally, I fed it to the UVs value of the Texture Sample you wish to Undistort.

I think I got it right, but I’m still trying to figure out how to use the Lens Calibrator to get my camera’s parameters.

 ![325955-screenshot-2020-12-30-152607.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/3/3/f3323782635db952d1bbf3f398acc0febbe6f0d2.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_c17aad921](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_c17aad921](https://forums.unrealengine.com/u/anonymous_user_c17aad921)\
**Post date:** [January 7, 2021, 6:47am UTC](https://forums.unrealengine.com/t/how-to-use-opencv-lensdistortion-plugin/476209/3 "2021-01-07T06:47:11Z")

</div>

@Roy

Thanks for the reply.

I have an additional question.

Is it correct that the BP in the first picture is an Actor?

I don’t know how to specify the Render Target.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2bf6072d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2bf6072d](https://forums.unrealengine.com/u/anonymous_user_2bf6072d)\
**Post date:** [January 11, 2021, 4:31am UTC](https://forums.unrealengine.com/t/how-to-use-opencv-lensdistortion-plugin/476209/4 "2021-01-11T04:31:44Z")

</div>

@m.takeshi, that is correct, the first BP is an Actor.
