How can i scale the servo motor from the info that i take from image?

5 views (last 30 days)
Hello. I'm working on my graduation project. Simply, it's a MatLAB based human tracking with camera and servo motors. I drive servos(MG995 model) with Arduino. The algorithm that I use is basicly like that.
(Let's assume 30 FramePerSecond WebCam)
Take the one Frame -->Find the human face(if exist)-->Drive servos to human face at image
My problem occurs when using servos. No problem with the face finding code, but the servos do not work well. I use the CascadeObjector to find the face.
sp_mid=0.5;%first servo position
integ=[0;0];
% PI constants for spin
kps=0.005;
kis=0.005;
detection = vision.CascadeObjectDetector();
bboxes = step(detection, frame);
if ~isempty(bboxes)
frame = insertObjectAnnotation(frame, 'rectangle', bboxes, 'Person','TextBoxOpacity', 0.4, 'FontSize', 10);
if exist('bboxes')
if ~isempty(bboxes)
%(bboxes(1)+bboxes(3)/2) is the point of face on x-axis
e=[ x_mid-(bboxes(1)+bboxes(3)/2);...
y_mid-(bboxes(2)+bboxes(4)/2)];
% scaling
e=e/10;
sp_val=sp_mid+kps*X_Point(1)+kis*integ(1);
writePosition(spin,sp_val);
How can I drive the servos to the face point that I find in the frame? My aim is to center the face at live video flow. Please, I need help.Thanks.

Answers (1)

Image Analyst
Image Analyst on 23 Mar 2019
I'd talk to the servo manufacturers to see if they have any MATLAB code to talk to their servos, especially through an Arduino.

Communities

More Answers in the  Power Electronics Control

Categories

Find more on Computer Vision Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!