Giter VIP home page Giter VIP logo

kaustubh-sadekar / virtualcam Goto Github PK

View Code? Open in Web Editor NEW
197.0 6.0 49.0 12.53 MB

Virtual camera is created only using opencv and numpy. It simulates a camera where we can control all its parameters, intrinsic and extrinsic to get a better understanding how each component in the camera projection matrix affects the final image of the object captured by the camera.

License: MIT License

Python 100.00%
computer-vision computer-graphics rendering camera-matrix camera-calibration camera-control camera-parameters fundamentals computer-vision-funamentals transformation-matrix

virtualcam's Introduction

VirtualCam

Virtual camera is created only using OpenCV and numpy. It simulates a camera where we can control all its parameters intrinsic and extrinsic to get a better understanding how each component in the camera projection matrix affects the final image of the object captured by the camera. It can be used to understand concepts of image formation and to understand the intrinsic and extrinsic camera parameters. An interractive GUI is also provided which simulates a virtual camera and a plane in 3D world. By changing the extrinsic parameters of the camera (rotation and translation) you can simulate how the image being formed changes.

Standard books related to multi-view geometry and computer vision were refered to ensure validty of equations in the code. I also refered this blog from learnopencv.com to understand the geometry of image formation. The opportuinity to sit through the CS763: Computer Vision Spring 2020 course at IIT Bombay also helped me to clear my fundamental concepts related to the geometry of image formation and camera projection matrix.

An interesting application of this library can be seen in FunMirrors project

Link to the post about FunMirrors

Instructions to run the GUI

  1. Install the virtual camera library using the following command
pip3 install vcam
  1. Clone the repositoy git clone https://github.com/kaustubh-sadekar/VirtualCam.git
  2. Run the GUI using the following command python3 GUI.py

Camera Translation

Camera-Translation

When you control the X, Y, Z trackerbars you are basically controlling the position of camera in the 3D world. The plane remains fixed and thus we can observe shifting of the plane as we move the camera. You can also objserve the changes in the last column of the camera projection matrix being prined in the right terminal.

Camera Rotation

Camera-Rotation

When you control the alpha, beta, gamma trackbars you are controlling the rotations of camera in 3D world. This gives turning effect to the image.

Camera Distortion Coefficients

Camera-Rotation

When you control the k and p trackbars you are controlling the distortion coefficients. The computations performed in numpy also take into account the equation for lens distortions for a pin hole camera.

Camera apparent pixel size and focal lenght

Camera-apparent-pixel-size-and-focus

When you control the sx and sy trackbars the apparent pixel size in x and y direction changes. As Sx increases the apparent pixel width increases making the image stretch horizontally and similarly Sy increases the apparent pixel height, making the image stretch vertically.

Basically the plane is a mesh of 3D points. We compute the camera projection matrix and thus the image coordinates corresponding to these 3D points. The projected points and the original mesh points are used to compute a map and finally a remapping function is applied on the image.

python3 GUI.py

Code files

GUI.py is the file for GUI to play with camera parameters.

virtualcam's People

Contributors

kaustubh-sadekar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

virtualcam's Issues

Distortion coefficient

Hello,

I'm trying to use GUI.py but I'm having some troubles with distortion coefficient: I see variation in the chessboard pattern only when I put the coefficients at their max value

k1, k2, p1, p2 trackbar values need offset

Thanks for this example program. For distortion input I suggest this:

	k1 = float(cv2.getTrackbarPos("K1",WINDOW_NAME))/100000. - 0.5
	k2 = float(cv2.getTrackbarPos("K2",WINDOW_NAME))/100000. - 0.5
	p1 = float(cv2.getTrackbarPos("P1",WINDOW_NAME))/100000. - 0.5
	p2 = float(cv2.getTrackbarPos("P2",WINDOW_NAME))/100000. - 0.5

virtual camera can used by other applications

hello, my friend, now I am facing one problem, I want to create an virtual camera, it process the frame captured from physical camera, and it's output can be use by other applications like OBS. how can I do this? appreciate your answer!

get new point coordinate

Hi, is there a simple way to link one point coordinate between the old img and the new ? Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.