Hello everyone, I need help. I am working on a robot arm project using MATLAB and a webcam to detect colors. Do you have any lessons or tutorials for me?

7 vues (au cours des 30 derniers jours)
Hello everyone, I’m working on a robot arm project using MATLAB and Arduino. I use my phone as a webcam to detect colors (like red or green). If the system detects a red object, the robot arm moves and picks it up, then puts it in the red storage area.
Now, I want to improve the project. Instead of the robot always picking red automatically, I want to click on an object in the camera video (GUI in MATLAB) to choose which color to pick — for example, if I click on a red object, it will pick up red. If I click on green, it will pick up green.
I find it hard to research or find tutorials. Can someone help me or guide me with examples or lessons?

Réponse acceptée

Image Analyst
Image Analyst le 24 Juin 2025
Sounds like you have a very controlled environment with known and fixed colors. What you could do with the image is to first mask the image to find all the red objects, and find all the green objects. You can get masks for those colors using the Color Thresholder on the Apps tab of the tool ribbon. Export one function for red, then find green and export the green function. Remember to change their names since they both can't use the same function name which the Export button exports.
Once you have the masks you might have to clean up the mask with functions like bwareafilt or bwareaopen to specify the size range you expect the colored regions to be in.
  14 commentaires
Image Analyst
Image Analyst le 30 Juin 2025
Yes but the webcam snaps an image. You can then call imwrite right after you snap it to save it to a file and upload it here. Otherwise, I gave you a demo where I track a green marker pen from a webcam so you can modify that.
Chan
Chan le 1 Juil 2025
Thank you sir if i have any problem can i ask you more

Connectez-vous pour commenter.

Plus de réponses (1)

Jacob Mathew
Jacob Mathew le 23 Juin 2025
Hi Chan,
Given that you already have a model to detect objects based on color, you can modify the code to return the various objects of color as a list. You can either select the object from the list of detected objects but if you want to use a GUI, then you can follow the below MATLAB Answers post where the author gets the coordinates from the clicked image:
You can then check whether the clicked coordinates is within the bounding box of the objects and if so, the corresponding object information can be passed onto the robotic arm to be picked up.
  2 commentaires
Chan
Chan le 26 Juin 2025

Thank you, sir. I was busy with my exam and project, so I forgot to reply. Sorry

Chan
Chan le 26 Juin 2025

It can detect the color when I right-click while moving

Connectez-vous pour commenter.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by