ECE PE5: Instrumentation & Control Track
“Computer Vision System with Applied
Robotics”
Instructor: Engr. Junard P. Kaquilala
Topics to discuss for this course:
1. Python Programming
2. Image Processing using Python and OpenCV
3. Musashi Alpha Robot
4. Programming with Musashi Alpha Robot
Passing Percentage & Grading System
I. Passing Percentage : 70%
II. Grading System
For Lecture Class:
Midterm Grade = 40%CS1 + 20% + 40%ME
Final Grade = 40%MG + 20%CS2 + 15%PFE + 15%FE +
10%MBE
Grading System
For Laboratory Class:
Midterm Grade = 60%CS1 + 40%ME
Final Grade = 50%MG + 30%CS2 + 20%FE
Overall Grade:
Midterm Grade = 50%MG(lec) + 50%MG(lab)
Final Grade = 50%FG(lec) + 50%FG(lab)
Examination
Type of Examination / Quiz
- Multiple Choice
- Discussion
- Application
Project
Project
Midterm Project: Image Processing using Python
Final Project: Computer Vision Robot System
Policy / Rules
Tardiness:
3 Lates = 1 Absent
Max. Allowable Absences = 3
Cheating is STRICTLY PROHIBITED
What is Python?
Python is an interpreted, high-level, general-purpose programming language.
Created by Guido van Rossum and first released in 1991, Python's design
philosophy emphasizes code readability with its notable use of significant
whitespace. Its language constructs and object-oriented approach aims to
help programmers write clear, logical code for small and large-scale projects.
https://en.wikipedia.org/wiki/Python_(programming_language)
What is
Python?
Why use
Python?
What can I
build with
Python?
Fundamentals of Python
Programming Language
Output Statement:
print function
print displays output to your console
print('Hello world')
Hello world
Enclose strings in single or double quotes
print('Hello world single quotes')
print("Hello world double quotes")
Hello world single quotes
Hello world double quotes
Printing blank lines can improve readability
print('Hello world')
print()
print('Did you see that blank line?')
print('Blank line \nin the middle of string')
Hello world
Did you see that blank line?
Blank line
in the middle of string
Printing multiple line statements using single printf
print(‘‘‘Hello World
Hi Cebu
Hi & Hello CIT-U ECE Students
Welcome to Python Programming’’’)
Hello World
Hi Cebu
Hi & Hello CIT-U ECE Students
Welcome to Python Programming
Debugging with print
print('Adding numbers')
x = 42 + 206
print('Performing division')
y = x / 0
print('Math complete')
Adding numbers
Performing division
Traceback (most recent call last):
File "demo.py", line 4, in <module>
y = x / 0
ZeroDivisionError: float division by zero
Comment
We add comments to our code using #
# This is a comment in my code it does nothing
Lines that start with # are not executed
# This is a comment in my code it does nothing
# print('Hello world')
# print("Hello world")
# No output will be displayed!
Comment calls to other programs to explain
their purpose
# Enable PIN check as listed in
# security requirements
enable_pin(current_user, pin)
Comments document your code so you and
other programmers can understand the code
# Using double quotes for this string because
# the string itself contains a single quote
print("It's a small world after all")
It's a small world after all
Commenting lines of code can help you debug and
figure out which line of code is causing an error
print('Hello world')
# print('It's a small world after all')
Hello world
Variables
Making variables
# declaration of variable in python
x = 10 # x is an integer
y = 2.5 # y is a floating point variable
str_1 = 'Welcome' # str_1 is a string variable
boolean_a = True # boolean_a is a Boolean variable
Input Statement:
input function
Getting information from the user
name = input('Please enter your name: ')
print(name)
Please enter your name: Susan
Susan
Type Conversion
Type conversion
# type conversion of variable
num1 = 10
num2 = 12.3
string_var = ‘11001’
print(float(num1))
print(int(num2))
print(int(string_var,2))
10.0
12
25
CommonType conversion
1. int(a,base): this function converts any data type
to integer
2. float(a): this function is used to convert an data
type to a floating point number
3. ord(a): this function is used to convert a
character to integer
4. hex(a): this function is to convert integer to
hexadecimal string
5. oct(a): this function is to convert integer to
octal string
6. str(a): used to convert integer into a string
7. complex(real,imag): converts real numbers to
Arithmetic Operators
Compound / Augmented Assignment Operator
# compound assignment
x += 10 # x = x + 10
y -= 5 # y = y – 5
z /= 2 # z = z / 2
a *= 3 # a = a * 3
Strings
String
String is a sequence of characters
To define a string, you can enclose the string in
matching single or double quotes
Example:
string1 = “Welcome to Python Programming”
string2 = ‘I am a string’
String indexing
Let:
s = ‘Hello Python’
Substring
# example of extracting a portion in a string
string1 = ‘Hello Python’
print(string1[0])
print(string1[len(string1)-1])
print(string1[-2])
print(string1[0:3])
H
n
o
Hel
Concatenating & Repeating Strings
# Strings can be added together with plus(+)
# operator
str1 = ‘Welcome’
str2 = ‘ ECE’
print(str1 + str2)
print(‘*^’*5)
Welcome ECE
*^*^*^*^*^
You can use functions to modify strings
sentence = 'The dog is named Sammy'
print(sentence.upper())
print(sentence.lower())
print(sentence.capitalize())
print(sentence.count('a'))
THE DOG IS NAMED SAMMY
the dog is named sammy
The dog is named sammy
2
The functions help us format strings we save to
files and databases, or display to users
first_name = input('What is your first name? ')
last_name = input('What is your last name? ')
print ('Hello ' + first_name.capitalize() + ' ' \
+ last_name.capitalize())
What is your first name? SUSAN
What is your last name? TAN
Hello Susan Tan
Formatting a string
first_name = input('What is your first name? ')
last_name = input('What is your last name? ')
print (f'Hello, {first_name} {last_name}’)
What is your first name? Junard
What is your last name? Kaquilala
Hello, Junard Kaquilala
End of Module 1
Thank you