Tutorial: Video Sensing + Color Detection

Alphabets Sounds Video

share us on:

In this tutorial, Erik from the Scratch team demonstrates how to utilize video sensing and color detection in Scratch to enhance interactive projects. He explains how to create a simple program where a cat sprite reacts to a red circle using the “touching color” block, and then expands on this concept by incorporating video sensing to interact with real-world objects, like a red Lego piece. The lesson encourages creativity by showcasing fun project ideas, such as a music-making program and a platform game, that leverage these features for engaging gameplay experiences.

Tutorial: Video Sensing + Color Detection

Hey everyone! I’m Erik from the Scratch team, and today I’m going to show you how to use video sensing and color detection in Scratch to create some amazing projects. Let’s dive in and learn how these features work!

Understanding Color Detection in Scratch

First, let’s talk about color detection. I’ve made a simple program where a cat sprite moves to the right when you press the right arrow key and to the left when you press the left arrow key. Now, let’s add some color sensing to make it more interesting!

To do this, I’ll go to the backdrop and draw a big red circle for the cat to interact with. Then, I’ll go back to the cat sprite and open the scripts. We want the cat to say “ow” when it touches the red circle. To make this happen, we’ll use a sensing block called “touching color.”

We’ll drag out the “touching color” block and use the color picker to select the red color. Next, we’ll create a script that says if the cat is touching the red color, it will say “ow.” But there’s a catch! This script only runs once when we click the green flag.

To fix this, we’ll put the script inside a forever loop, so it keeps checking if the cat is touching the color. Now, when we run the program, the cat says “ow” whenever it touches the red shape. Cool, right?

Exploring Video Sensing

Now, let’s make it even cooler by using video sensing. This feature lets us use a webcam to interact with our Scratch projects. I’ll start with a white backdrop and turn on the video sensing using the “turn video on” block from the sensing category. This activates the webcam, and you can see the view on the screen.

Instead of drawing on the backdrop, I’ll use a red Lego piece. I’ll place it on the stage, and the webcam will detect its color. We’ll use the same “touching color” concept here. I’ll select the red color of the Lego, and now the webcam can detect it. This opens up many fun possibilities!

Fun Projects with Video Sensing and Color Detection

Let me show you some examples of what you can do with these features:

Music-Making Program

I created a music program where a black bar moves across the screen. When it touches a Lego of a certain color, it plays a specific note. For example, it plays a C note when touching green, an E note when touching orange, and an A note when touching red. You can make your own music with this idea!

Juggling Game

In another project, you can juggle cats and dogs based on the color of balloons. I made a large black sprite that covers the screen and is transparent. It triggers sounds when touched, even though you can’t see it. It’s like magic!

Platform Game

I also made a simple platform game using video sensing. In this game, green acts as a bounce pad, red is lava, and black is the ground. I remixed an existing platform game, and you can see how the scripts use the “when touching color” block to interact with different elements. It’s super fun to play!

I encourage you to explore some platformer tutorials on YouTube and Scratch. The idea of having objects you can interact with in real-time is really exciting. I’ll share links to all the projects in the video description, so you can check them out and remix them. Have a great time creating and experimenting with video sensing and color detection. It’s amazing to see what you can make!

  1. What aspects of video sensing and color detection in Scratch did you find most intriguing, and why?
  2. How do you think the integration of video sensing can enhance the interactivity of Scratch projects?
  3. Reflect on a project idea you have that could utilize color detection. How would you implement it based on what you learned?
  4. What challenges do you anticipate when using the “touching color” block in your own projects, and how might you overcome them?
  5. How does the concept of using a webcam for video sensing open up new possibilities for creative projects?
  6. In what ways do you think the use of real-world objects, like the red Lego piece, can impact the learning experience in Scratch?
  7. Consider the examples provided, such as the music-making program and juggling game. How might you expand on these ideas?
  8. What are some potential educational benefits of using video sensing and color detection in classroom settings?
  1. Create a Color Detection Game

    Design a simple game where you control a sprite using the arrow keys. Draw different colored shapes on the backdrop. Use the “touching color” block to make your sprite react differently to each color. For example, make the sprite say “ouch” when touching red and “yay” when touching green. Experiment with different reactions and colors!

  2. Video Sensing Challenge

    Turn on the video sensing feature in Scratch and use your webcam to interact with your project. Place a colored object in front of the camera and program your sprite to react when it detects that color. Try using different objects and see how the sprite responds. Can you create a game where you score points by showing the right color?

  3. Music Maker with Colors

    Create a musical project where different colors play different notes. Use the “touching color” block to detect when a sprite touches a specific color and play a corresponding sound. Arrange colored objects on the screen and see if you can compose a song by moving your sprite over them!

  4. Interactive Storytelling

    Develop a story where the plot changes based on the colors your sprite touches. Use the “touching color” block to trigger different story events. For example, touching blue could lead to a rainy day scene, while touching yellow might bring out the sun. Get creative and see how colors can change your story!

  5. Design a Platform Game

    Use video sensing to create a platform game where different colors represent different types of terrain. Program your sprite to jump on green platforms, avoid red lava, and walk on black ground. Experiment with different levels and challenges. Can you make a game that’s both fun and challenging?

Here’s a sanitized version of the provided YouTube transcript:

[Music]

Hey everyone, it’s Erik here from the Scratch team! I’m excited to show you how to use video sensing and color detection in Scratch to create some remarkable programs.

Let’s start by familiarizing ourselves with the concept of color detection in Scratch. I’ve created a simple program where, as you can see, if I press the right arrow key, the cat moves to the right, and if I press the left arrow key, the cat moves to the left.

Now, what if we want to add some color sensing to this project? I’ll go to the backdrop and create something red for the cat to interact with. I’ve clicked on the backdrop and drawn a large red circle.

Next, I’ll return to my Scratch cat sprite and go to the scripts. We want to say that if the cat touches this red shape, it will say “ow.” To do this, we’ll use a sensing block. We’ll create a statement that uses the “touching color” block.

Let’s drag this out and select the color we want to interact with by clicking the button to use the color picker. I’ll select the red color. Now, we need to build a script around this.

When the green flag is clicked, we’ll create an if-then statement. If the Scratch cat is touching this color, it will say “ow.” However, this won’t work as expected because the if-then statement only gets asked once when the green flag is clicked.

To fix this, we need to wrap this question in a forever loop, so it continuously checks if the cat is touching the color. Let’s run it again. Great! Now we have a simple program where the Scratch cat says “ow” when it touches the red shape.

But let’s take this a step further. Wouldn’t it be cool if the Scratch cat could interact with objects in the physical world? We can do this using video sensing, which allows us to use the webcam to interact with Scratch projects.

I’ll start with a white backdrop. Now, let’s enable video sensing. In the sensing category, I’ll use the “turn video on” block. This will activate the webcam. You can see the webcam view here, pointing down at a sheet of white paper.

Now, instead of drawing on the backdrop, let’s use a red Lego piece. I’ll grab a Lego and place it on the stage. The same concept of “when touching” will work here.

I’ll select the red color of the Lego, which is a slightly darker shade. Now, the webcam and video sensing can detect the color. This opens up many possibilities for interaction.

Let me show you a few examples of what you can do with video sensing and color detection.

Here’s a music-making program I created. It features a black bar that moves across the screen, and when it touches a Lego of a certain color, it plays a specific note. For example, it plays a C note when touching green, an E note when touching orange, and an A note when touching red.

Another project allows you to juggle cats and dogs based on the color of balloons. I created a large black sprite that takes up the entire screen and made it transparent so it triggers sounds when touched, even though it’s hidden.

Finally, I made a simple platform game using video sensing. The green acts as a bounce pad, the red represents lava, and the black is the ground. I’ve remixed an existing platform game, and you can see how the scripts use the “when touching color” block to interact with the different elements.

I encourage you to check out some platformer tutorials available on YouTube and Scratch. The basic concept of having movable objects that you can interact with in real-time is really exciting.

I’ll provide links to all the projects I’ve shared in the description of the video, so you can check them out and remix them. I wish everyone a great time creating and experimenting with video sensing and color detection. It’s amazing to see what you can make!

This version removes informal language and maintains a professional tone while preserving the instructional content.

VideoA moving picture that you can watch on a computer or other device. – We watched a video on how to create a simple game using coding.

SensingThe ability of a computer or program to detect or feel something, like movement or sound. – The robot uses sensing technology to avoid obstacles in its path.

ColorA property of an object that can be seen, such as red, blue, or green, often used in computer graphics. – We changed the color of the sprite to make it more visible on the screen.

DetectionThe process of finding or identifying something, often used in coding to find specific conditions or inputs. – The program includes motion detection to start recording when someone enters the room.

SpriteA character or object in a computer game or animation that can be moved and controlled. – I created a sprite of a cat that can jump over obstacles in the game.

ProgramA set of instructions that a computer follows to perform a task. – We wrote a program to calculate the average of our test scores.

ScriptA list of commands in a program that tells the computer what to do. – The script we wrote makes the sprite move across the screen when we press the arrow keys.

WebcamA camera that connects to a computer and is used to take pictures or videos. – We used the webcam to record our coding project presentation.

ProjectsActivities or tasks that involve creating something, often using coding or technology. – Our class worked on projects to design our own video games using Scratch.

InteractTo communicate or work together with a computer program or device. – The game allows players to interact with different characters by clicking on them.

All Video Lessons

Login your account

Please login your account to get started.

Don't have an account?

Register your account

Please sign up your account to get started.

Already have an account?