# Dolly Zoom Effect

**URL:** <https://forum.opencv.org/t/dolly-zoom-effect/2618>\
**Category:** Python\
**Created:** [April 6, 2021, 9:13am UTC](https://forum.opencv.org/t/dolly-zoom-effect/2618 "2021-04-06T09:13:06Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vkash\_Poudel](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/vkash_poudel/32/1730_2.png) [@Vkash\_Poudel](https://forum.opencv.org/u/Vkash_Poudel)\
**Post date:** [April 6, 2021, 9:13am UTC](https://forum.opencv.org/t/dolly-zoom-effect/2618/1 "2021-04-06T09:13:06Z")

</div>

**Dolly Zoom Effect**  
How to create dolly zoom effect in real time or to say vertigo effect in realtime.

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [April 6, 2021, 10:53am UTC](https://forum.opencv.org/t/dolly-zoom-effect/2618/2 "2021-04-06T10:53:25Z")

</div>

why are you asking in a computer-vision forum for some game effect ?

---

<div class="post-metadata">

**Author:** ![Vkash\_Poudel](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/vkash_poudel/32/1730_2.png) [@Vkash\_Poudel](https://forum.opencv.org/u/Vkash_Poudel)\
**Post date:** [April 6, 2021, 11:17am UTC](https://forum.opencv.org/t/dolly-zoom-effect/2618/3 "2021-04-06T11:17:49Z")

</div>

Yes with computer-vision for cinematic view

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [April 6, 2021, 12:25pm UTC](https://forum.opencv.org/t/dolly-zoom-effect/2618/4 "2021-04-06T12:25:45Z")

</div>

what’s your input data?

can you show examples of what effect you mean?

and please present the results of your literature research (googling). don’t say there’s nothing. there is.

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [April 6, 2021, 1:28pm UTC](https://forum.opencv.org/t/dolly-zoom-effect/2618/5 "2021-04-06T13:28:26Z")

</div>

there is no magic behind zooming.

- you pick a ROI to zoom in
- you resize() it

---

<div class="post-metadata">

**Author:** ![kbarni](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/kbarni/32/26_2.png) [@kbarni](https://forum.opencv.org/u/kbarni)\
**Post date:** [April 6, 2021, 1:42pm UTC](https://forum.opencv.org/t/dolly-zoom-effect/2618/6 "2021-04-06T13:42:59Z")

</div>

A simple zoom is possible with a crop/resize, but for a dolly-zoom you need 3D data, as it changes the image based on the scene.

If you have full 3D data of the scene (it has been modeled in 3D), just use a 3D rendering engine, game engine etc. Change the position of the camera together with the field of view.

If you have partial 3D data (let’s say from a RGB-D camera), you can simulate this effect by projecting the point cloud with different camera positions and field of view; but you’ll have missing data (the part of the image that’s hidden in the original shot. It is possible to reconstruct some of this data using [_inpainting_](https://docs.opencv.org/master/df/d3d/tutorial_py_inpainting.html), but it will be _guessed_ data, far from _cinematic quality_.

---

<div class="post-metadata">

**Author:** ![Vkash\_Poudel](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/vkash_poudel/32/1730_2.png) [@Vkash\_Poudel](https://forum.opencv.org/u/Vkash_Poudel)\
**Post date:** [April 7, 2021, 7:21am UTC](https://forum.opencv.org/t/dolly-zoom-effect/2618/7 "2021-04-07T07:21:46Z")

</div>

[![](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/8/86d6a3a7e0d8e23c4b96be748dabdd927670a853.jpeg "AI OpenCV Dolly Zoom Camera") ](https://www.youtube.com/watch?v=aujQVz2TPN0)

just like this

---

<div class="post-metadata">

**Author:** ![kbarni](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/kbarni/32/26_2.png) [@kbarni](https://forum.opencv.org/u/kbarni)\
**Post date:** [April 7, 2021, 8:30am UTC](https://forum.opencv.org/t/dolly-zoom-effect/2618/8 "2021-04-07T08:30:25Z")

</div>

That’s not dolly zoom. It’s only a simple crop around the face of a guy walking around. For a dolly zoom you need a fixed subject and a moving/zooming camera. [This is a classic](https://www.youtube.com/watch?v=_eO_5q5dR9M) dolly-zoom effect.

To achieve the effect from your video, no need for AI. Do a [face detection](https://docs.opencv.org/3.4/db/d28/tutorial_cascade_classifier.html), then instead of drawing a circle, just crop the image around the detected face.

```
//after detectMultiScale() function
//using the first detected face: get the center and the radius. 
Point center( faces[0].x + faces[0].width/2, faces[0].y + faces[0].height/2 );
int radius = (faces[0].width + faces[0].height)/4;
//crop the face with a certain border...
Mat dest = src(Rect(center.x-radius*8/3,center.y-radius*2,radius*16/3,radius*4);
//resize the cropped image to a constant size and display it
Mat dest2;
resize(dest,dest2,Size(400,300);
imshow("DollyZoom",dest2);
```

---

<div class="post-metadata">

**Author:** ![Vkash\_Poudel](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/vkash_poudel/32/1730_2.png) [@Vkash\_Poudel](https://forum.opencv.org/u/Vkash_Poudel)\
**Post date:** [April 7, 2021, 10:15am UTC](https://forum.opencv.org/t/dolly-zoom-effect/2618/9 "2021-04-07T10:15:57Z")

</div>

thanks for the reply , I want to request you again for same code in python.

---

<div class="post-metadata">

**Author:** ![kbarni](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/kbarni/32/26_2.png) [@kbarni](https://forum.opencv.org/u/kbarni)\
**Post date:** [April 7, 2021, 11:17am UTC](https://forum.opencv.org/t/dolly-zoom-effect/2618/10 "2021-04-07T11:17:12Z")

</div>

Sorry, this is not a request / solve my homework forum.

---

<div class="post-metadata">

**Author:** ![Vkash\_Poudel](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/vkash_poudel/32/1730_2.png) [@Vkash\_Poudel](https://forum.opencv.org/u/Vkash_Poudel)\
**Post date:** [April 7, 2021, 11:25am UTC](https://forum.opencv.org/t/dolly-zoom-effect/2618/11 "2021-04-07T11:25:05Z")

</div>

I’m sorry if I used inappropriate language,  
forgive me ,  
Please
