SOLFIND
Web Lens
Portal home

GitHub - maxbak753/IMGS621-Computer-Vision-Project · GitHub

https://github.com/maxbak753/IMGS621-Computer-Vision-Project • 270 KB fetched
Open original page


GitHub - maxbak753/IMGS621-Computer-Vision-Project · GitHub

Skip to content

Navigation Menu

Sign in Appearance settings

* Platform
* AI CODE CREATION
* GitHub Copilot Write better code with AI

* GitHub Copilot app Direct agents from issue to merge

* MCP Registry Integrate external tools

* DEVELOPER WORKFLOWS
* Actions Automate any workflow

* Codespaces Instant dev environments

* Issues Plan and track work

* Code Review Manage code changes

* Code Quality Enforce quality at merge

* APPLICATION SECURITY
* GitHub Advanced Security Find and fix vulnerabilities

* Code security Secure your code as you build

* Secret protection Stop leaks before they start

* EXPLORE
* Why GitHub

* Documentation

* Blog

* Changelog

* Marketplace

View all features

* Solutions
* BY COMPANY SIZE
* Enterprises

* Small and medium teams

* Startups

* Nonprofits

* BY USE CASE
* App Modernization

* DevSecOps

* DevOps

* CI/CD

* View all use cases

* BY INDUSTRY
* Healthcare

* Financial services

* Manufacturing

* Government

* View all industries

View all solutions

* Resources
* EXPLORE BY TOPIC
* AI

* Software Development

* DevOps

* Security

* View all topics

* EXPLORE BY TYPE
* Customer stories

* Events & webinars

* Ebooks & reports

* Business insights

* GitHub Skills

* SUPPORT & SERVICES
* Documentation

* Customer support

* Community forum

* Trust center

* Partners

View all resources

* Open Source
* COMMUNITY
* GitHub Sponsors Fund open source developers

* PROGRAMS
* Security Lab

* Maintainer Community

* GitHub Stars

* Archive Program

* REPOSITORIES
* Topics

* Trending

* Collections

* Enterprise
* ENTERPRISE SOLUTIONS
* Enterprise platform AI-powered developer platform

* AVAILABLE ADD-ONS
* GitHub Advanced Security Enterprise-grade security features

* Copilot for Business Enterprise-grade AI features

* Premium Support Enterprise-grade 24/7 support

* Pricing
Search /

Sign in
Sign up Appearance settings

You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.

Dismiss alert

maxbak753

/

IMGS621-Computer-Vision-Project

Public

*
Notifications
You must be signed in to change notification settings

*
Fork
0

*

Star
0

*

Code

*

Issues
0

*

Pull requests
0

*

Actions

*

Projects

*

Security and quality
0

*

Insights

Additional navigation options

*

Code

*

Issues

*

Pull requests

*

Actions

*

Projects

*

Security and quality

*

Insights

main

Branches Tags

Go to file

Code Open more actions menu

Latest commit
 

History
25 Commits
25 Commits

Folders and files
Name Name Last commit message
Last commit date

Images

Images

 
 

Old

Old

 
 

Videos

Videos

 
 

Artificial_DOF_VideoRead.ipynb

Artificial_DOF_VideoRead.ipynb

 
 

Artificial_DOF_Webcam.ipynb

Artificial_DOF_Webcam.ipynb

 
 

IMGS-621 Project - Max Bakalos.pdf

IMGS-621 Project - Max Bakalos.pdf

 
 

ReadMe.md

ReadMe.md

 
 

pip_requirements_anaconda.txt

pip_requirements_anaconda.txt

 
 

View all files

Repository files navigation

*

* README

More items

Automatic Synthetic Object Focusing with Shallow Depth of Field Lens

IMGS-621 Computer Vision

Max Bakalos
PDF Version of ReadMe

There are two versions of the program:

* Artificial_DOF_Webcam.ipynb   ← livestreams from a webcam

* Artificial_DOF_VideoRead.ipynb   ← reads a pre-recorded video file

Artificial Shallow Depth of Field

Overview

I proposed a method that would use an existing object detection program (YOLO) to track some moving
object in a wide depth of field (DOF) camera, estimate the depth of the object, then adjust the focal length
of another closely spaced shallow DOF camera to bring the object into focus using a camera control
software. However, I ran out of time to complete the camera-control aspect of the project, which is mostly
out of the scope of the computer vision class anyway. As an adjustment to the original project idea, I
instead implemented an artificial shallow depth of field effect, similar to “portrait mode” in modern
smartphones.
Methods

Three separate problems fit together in a chain of events in order to blur everything besides a certain
distance from the camera: object detection, depth estimation, and selective artificial blurring. For the
unused 2nd camera approach, calculating the angle of the focus ring on the camera lens would replace
selective artificial blurring.
Implementation

I implemented my code in a Python Jupyter Notebook and used OpenCV to stream video frames from a
webcam. To detect objects in the frames, the pretrained YOLOv26 model was used (PyTorch). The object
in question was a tennis ball that could be classified as a “sports ball” by the model. It was quite effective
at finding the tennis ball; however, it struggled at larger relative object sizes in the frame (closer to the
camera).
To get a depth image from the monocular setup, the DepthAnythingV2 library was used. Once a depth map
was acquired, the region of interest (ROI) from the object detector was cut out of the corresponding
location in the depth image. Since the tennis ball is round, the corners of the square ROI bounding box
held inaccurate depth information, so only a central fractional sub-ROI was taken. This sub-region’s pixel
depth values were then averaged to find the approximate depth of the front center of the ball.
The final step involved artificially blurring the frame. To do this, the frame must be segmented into four
depth regions. A depth error is calculated between the object and the rest of the frame, and this is
segmented into 4 groups based on thresholds. These 4 masked binary groups are then blurred to smooth
the transitions. The 1st mask has no blur, 2nd has a bit of blur, the 3rd has medium blur, and the 4th has
heavy blur. Each image is multiplied by the mask and then combined into the final output image.

Conclusion

Overall, the project worked well, but it could be improved in many ways. First, the depth blurring could be
thresholded into more segments to improve the smoothness, and maybe use a more physics-based
blurring approach.
Also, of course, I would like to implement this with another real camera and spin the focus ring to keep an
object at a constant depth. I plan to continue this project in the future.

Part II

Core

Use an existing object detection program (YOLO) to track some moving object in a wide DOF camera, estimate the depth of the object, then adjust the focal length of another closely spaced shallow DOF camera to bring the object into focus using a camera control software.
Deliverable

A comparison of human focusing and machine focusing using sharpness index (confusion matrix), video of camera automatically focusing for specific object
References

[1] Chou, Jean-Peic. “Synthetic Depth-Aware Defocus and Controllable Bokeh for Stylized Photography.” CS231n: Deep Learning for Computer Vision, Stanford University, https://cs231n.stanford.edu/reports/2022/pdfs/90.pdf .

[2] “Object Detection.” Ultralytics YOLO Docs, Ultralytics, 20 Apr. 2026, https://docs.ultralytics.com/tasks/detect/ .

[3] Yang, Lihe, et al. Depth Anything, CVPR, 2024, https://depth-anything.github.io/ .

About
No description, website, or topics provided.
Resources
Readme
Activity
Stars
0 stars
Watchers
0 watching
Forks
0 forks
Report repository

Releases

Packages

Contributors

Languages

Footer

(c) 2026 GitHub, Inc.

Footer navigation

*
Terms

*
Privacy

*
Security

*
Status

*
Community

*
Docs

*
Contact

*

Manage cookies

*

Do not share my personal information

You can’t perform that action at this time.

Links found on this page

  1. Skip to content [direct]
  2. Sign in [direct]
  3. GitHub Copilot Write better code with AI [direct]
  4. GitHub Copilot app Direct agents from issue to merge [direct]
  5. MCP Registry Integrate external tools [direct]
  6. Actions Automate any workflow [direct]
  7. Codespaces Instant dev environments [direct]
  8. Issues Plan and track work [direct]
  9. Code Review Manage code changes [direct]
  10. Code Quality Enforce quality at merge [direct]
  11. GitHub Advanced Security Find and fix vulnerabilities [direct]
  12. Code security Secure your code as you build [direct]
  13. Secret protection Stop leaks before they start [direct]
  14. Why GitHub [direct]
  15. Documentation [direct]
  16. Blog [direct]
  17. Changelog [direct]
  18. Marketplace [direct]
  19. View all features [direct]
  20. Enterprises [direct]
  21. Small and medium teams [direct]
  22. Startups [direct]
  23. Nonprofits [direct]
  24. App Modernization [direct]
  25. DevSecOps [direct]
  26. DevOps [direct]
  27. CI/CD [direct]
  28. View all use cases [direct]
  29. Healthcare [direct]
  30. Financial services [direct]
  31. Manufacturing [direct]
  32. Government [direct]
  33. View all industries [direct]
  34. View all solutions [direct]
  35. AI [direct]
  36. Software Development [direct]
  37. DevOps [direct]
  38. Security [direct]
  39. View all topics [direct]
  40. Customer stories [direct]
  41. Events & webinars [direct]
  42. Ebooks & reports [direct]
  43. Business insights [direct]
  44. GitHub Skills [direct]
  45. Customer support [direct]
  46. Community forum [direct]
  47. Trust center [direct]
  48. Partners [direct]
  49. View all resources [direct]
  50. GitHub Sponsors Fund open source developers [direct]
  51. Security Lab [direct]
  52. Maintainer Community [direct]
  53. GitHub Stars [direct]
  54. Archive Program [direct]
  55. Topics [direct]
  56. Trending [direct]
  57. Collections [direct]
  58. Copilot for Business Enterprise-grade AI features [direct]
  59. Premium Support Enterprise-grade 24/7 support [direct]
  60. Pricing [direct]
  61. Sign up [direct]
  62. maxbak753 [direct]
  63. Notifications [direct]
  64. Issues 0 [direct]
  65. Pull requests 0 [direct]
  66. Actions [direct]
  67. Projects [direct]
  68. Security and quality 0 [direct]
  69. Insights [direct]
  70. Branches [direct]
  71. Tags [direct]
  72. 25 Commits [direct]
  73. Images [direct]
  74. Old [direct]
  75. Videos [direct]
  76. Artificial_DOF_VideoRead.ipynb [direct]
  77. Artificial_DOF_Webcam.ipynb [direct]
  78. IMGS-621 Project - Max Bakalos.pdf [direct]
  79. ReadMe.md [direct]
  80. pip_requirements_anaconda.txt [direct]