How can I have a video ouput with my code?
Info
This question is closed. Reopen it to edit or answer.
Show older comments
Hi, I was recently helped with detecting a line in an image. I have made some changes and I wan't to have a video input in stead of an image. Unfortunately, when I put a video input it just gives me the videoscreen as a picture. Underneath I have displayed the Simulink model. The structure is as follow:
Video --> Find line (doellijndetectie) --> find circles --> display to video
The aim of this code is to find the soccerline and the football and determine if it's a goal or not

My first code in "doellijndetectie" is a code that is an extrinsic and recalls a Matlab code:
function stop=doellijndetectie(veld)
% sizing van uitgang sz = size(u);
%y=veld;
% hele functie is extrinsic:
coder.extrinsic('Doellijn2');
%functie oproep: DOELLIJN2
Doellijn2(veld);
stop=veld;
Above is the extrinsic that calls the following code:
function y=Doellijn2(I)
%%%y size declareren
y=(I);
% Foto goal inlezen
%I = imread('strafschopgebied.png');
Igray = rgb2gray(I);
% Het zwarte gebied eruit filteren dat dichtbij BoundingBox zit
BW = imbinarize(Igray);
BW = imclearborder(~BW);
stats = struct2table(regionprops(BW));
ratio = stats.Area./(stats.BoundingBox(:,3).*stats.BoundingBox(:,4));
[~, idx] = max(ratio);
stats = stats(idx,:);
% GoalLijn (= Onderrand van BoundingBox)
goalLijn = [...
stats.BoundingBox(1),stats.BoundingBox(2)+stats.BoundingBox(4);
stats.BoundingBox(1)+stats.BoundingBox(3),stats.BoundingBox(2)+stats.BoundingBox(4)];
y1 = stats.BoundingBox(1);
x1 = stats.BoundingBox(2)+stats.BoundingBox(4);
x2 = y1 + stats.BoundingBox(3);
y2 = x1 + stats.BoundingBox(4);
% Presentatie van het resultaat
figure
imshow(I)
hold on
y=plot(goalLijn(:,1),goalLijn(:,2),'c','LineWidth',4)
message = sprintf(['The value for x1: %f' 'The value for x2: %f' 'The value for y1: %f' 'The value for y2: %f'],[x1 x2 y1 y2])
uiwait(helpdlg(message));
The the "findCircles" code is:
function output_image = findCircels(Gevoeligheid,stop,StraalMin,StraalMax)
%#codegen
output_image = stop;
coder.extrinsic('imfindcircles');
[centers,radii] = imfindcircles(stop,[StraalMin, StraalMax], 'ObjectPolarity','dark', 'Sensitivity',Gevoeligheid,'Method','twostage');
stop = insertShape(stop,'Circle',[centers radii],'LineWidth',5);
output_image = stop;
When I press on play in Simulink it goes on and on in a loop.. and I get the following outputs:

Output 2 if from the Matlab function "Doellijndetectie"

I only need a video output that let's me know if it's a goal or not. I already have the line coordinates (almost the ball..)
Answers (0)
This question is closed.
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!