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
- Skip to content [direct]
- Sign in [direct]
- GitHub Copilot Write better code with AI [direct]
- GitHub Copilot app Direct agents from issue to merge [direct]
- MCP Registry Integrate external tools [direct]
- Actions Automate any workflow [direct]
- Codespaces Instant dev environments [direct]
- Issues Plan and track work [direct]
- Code Review Manage code changes [direct]
- Code Quality Enforce quality at merge [direct]
- GitHub Advanced Security Find and fix vulnerabilities [direct]
- Code security Secure your code as you build [direct]
- Secret protection Stop leaks before they start [direct]
- Why GitHub [direct]
- Documentation [direct]
- Blog [direct]
- Changelog [direct]
- Marketplace [direct]
- View all features [direct]
- Enterprises [direct]
- Small and medium teams [direct]
- Startups [direct]
- Nonprofits [direct]
- App Modernization [direct]
- DevSecOps [direct]
- DevOps [direct]
- CI/CD [direct]
- View all use cases [direct]
- Healthcare [direct]
- Financial services [direct]
- Manufacturing [direct]
- Government [direct]
- View all industries [direct]
- View all solutions [direct]
- AI [direct]
- Software Development [direct]
- DevOps [direct]
- Security [direct]
- View all topics [direct]
- Customer stories [direct]
- Events & webinars [direct]
- Ebooks & reports [direct]
- Business insights [direct]
- GitHub Skills [direct]
- Customer support [direct]
- Community forum [direct]
- Trust center [direct]
- Partners [direct]
- View all resources [direct]
- GitHub Sponsors Fund open source developers [direct]
- Security Lab [direct]
- Maintainer Community [direct]
- GitHub Stars [direct]
- Archive Program [direct]
- Topics [direct]
- Trending [direct]
- Collections [direct]
- Copilot for Business Enterprise-grade AI features [direct]
- Premium Support Enterprise-grade 24/7 support [direct]
- Pricing [direct]
- Sign up [direct]
- maxbak753 [direct]
- Notifications [direct]
- Issues
0 [direct]
- Pull requests
0 [direct]
- Actions [direct]
- Projects [direct]
- Security and quality
0 [direct]
- Insights [direct]
- Branches [direct]
- Tags [direct]
- 25 Commits [direct]
- Images [direct]
- Old [direct]
- Videos [direct]
- Artificial_DOF_VideoRead.ipynb [direct]
- Artificial_DOF_Webcam.ipynb [direct]
- IMGS-621 Project - Max Bakalos.pdf [direct]
- ReadMe.md [direct]
- pip_requirements_anaconda.txt [direct]