EBU7240 Computer Vision
Semester 1, 2021
Changjae Oh
coursework
Copyright By PowCoder代写 加微信 powcoder
• Setting up your playground
• Python / examples
• OpenCV / examples
• Following slides are guidelines for those who start Python from scratch
• You can use your own way to setup the environment
• BUT make sure that your code is runnable in the provided environment:
̶ ̶ ̶ ̶ ̶ ̶
Python 3.8
opencv-python opencv-contrib-python matplotlib
• A free and open-source distribution of the Python languages
̶ for scientific computing (data science, machine learning applications, large-scale data processing, predictive analytics, etc.),
̶ aims to simplify package management and deployment.
• A free minimal installer for conda.
̶ A small, bootstrap version of Anaconda that includes only conda, Python, the package s they depend on, and a small number of other useful packages, including pip, zlib and a few others.
(Anaconda)
̶ https://docs.conda.io/en/latest/miniconda.html
Download → Install
• Making your Python coding easier
• Download -> Install!
1. Your directory
Your name! QM number!
2. Put “requirements.txt” (in QMPlus) in the above folder
3. Run Anaconda Prompt
4. Create the virtual environment (your playground)
5. Activate the environment
6. Installing packages from “requirements.txt”
Your virtual environment includes all libraries you need for this module Now, let’s connect this virtual environment with PyCharm
9. Open PyCharm -> Projects -> 10. Set location as your folder
11. Previously configured interpreter→click “…”
12. Load your conda environment
13. Click “OK”→“Create”→“Create from Existing Sources”
13. Create the subfolders you will need
14. Put any image in ./inputs/
15. Create python File in the ./codes/
16. Right click -> Run
Now you are ready to code!
Useful tips • Debug
• Setting up your playground • Python
Why Python?
Top 10 Reasons Why Python is So Popular With Developers in 2022
) vs MATLAB
• Setting up your playground • Python
Image Read
• cv2.imread()
̶ Loads an image from a file
̶ If the image cannot be read (because of missing file, improper permissions, unsupport ed or invalid format), returns an empty matrix (Mat::data == NULL)
➢filename – Name of file to be loaded
➢flags – Flag that can take values of cv::ImreadModes
Image Show
• cv2.imshow()
̶ Displays an image in the specified window
Image Write
• cv2.imwrite()
̶ Saves an image to a specified file
• Read Lena.jpg with colour and greyscale and show them
Image Read / Write
• Read Lena.jpg with colour and greyscale and show them
Image Read / Write
• Resize the Lena image to half resolution and composite as shown below:
Image Composition with
• Resize the Lena image to half resolution and composite as shown below:
Image Composition with
Perspective Projection
Given two point sets:
̶ 𝒙 = 𝒙 ,…,𝒙 = 𝑢 ,𝑣 ,…,(𝑢 ,𝑣 ) = (41,176),(67,1133),(749,16),(749,1270) 141144
̶ 𝒙′ = 𝒙′1, … , 𝒙′4 = 𝑢′1, 𝑣′1 , … , (𝑢′4, 𝑣′4) = (0, 0), (0,1280), (749,0), (749,1280) Find the perspective projection matrix 𝑷 such that 𝒙′ = 𝑷𝒙 and warp the image
Perform perspective projection
Perspective Projection
Perspective Projection
Perspective Projection
Given two point sets:
̶ 𝒙 = 𝒙 ,…,𝒙 = 𝑢 ,𝑣 ,…,(𝑢 ,𝑣 ) = (41,176),(67,1133),(749,16),(749,1270) 141144
̶ 𝒙′ = 𝒙′1, … , 𝒙′4 = 𝑢′1, 𝑣′1 , … , (𝑢′4, 𝑣′4) = (0, 0), (0,1280), (749,0), (749,1280) Find the perspective projection matrix 𝑷 such that 𝒙′ = 𝑷𝒙 and warp the image
Perform perspective projection
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com