As we plan our AI robot to play Connect-4, we have decided that Python would be a good programming language for the job, as it is widely used for many of the tasks we will need to do:
- Computer vision
- Artificial intelligence
- Hardware control
Therefore, we spent time this week brushing up on Python. Following the same approach that we had used previously to move from Scratch to C, we looked at how we would move from programming in Scratch to Python.
Here is the full set of notes (PDF): CoderDojo-Hackers-IntroToPython
Kevin then spent time explaining how to write a basic Python program to read an image from a webcam. Here is the code:
# We are using OpenCV import cv2 # Capture webcam image camera=cv2.VideoCapture(0) val, img = camera.read() # Display the image cv2.imshow("Window display", img) # Stop using the camera camera.release