MATLAB -Colour Detection code deployment

I have created an project that detects colours and gives out the distance between them ,How do i create a standalone executable for the same .I have tried Application compiler but it gives me an error as imaqtool/Apps and GUI cannot be compiled using .
Kindly suggest any alternative deployment method thatcan be run without launching MATLAB

답변 (1개)

Image Analyst
Image Analyst 2018년 2월 18일

0 개 추천

imaqtool is an applet with a GUI (controls image capture from cameras), and, like all other such applets in MATLAB, are not allowed to be compiled and shipped with your standalone executable.
You can use that tool to create code that you can then paste into your program, but you can't call imaqtool itself from your program in the compiled, standalone program.

댓글 수: 1

Apologies i may have created a bit of confusion!
I have built an exe from the below .m file.On clicking a button that launches the webcam i get the below error in cmd.
function TEST()
S = uicontrol('Style', 'PushButton', ...
'String', 'STOP', ...
'Position', [220 250 200 60],...
'Callback', @stopp);
R = uicontrol('Style', 'PushButton', ...
'String', 'Red', ...
'Position', [220 50 200 60],...
'Callback', @redd);
G = uicontrol('Style', 'PushButton', ...
'String', 'Green', ...
'Position', [220 150 200 60],...
'Callback', @greenn);
G = uicontrol('Style', 'PushButton', ...
'String', 'White', ...
'Position', [220 150 200 60],...
'Callback', @white);
function red=redd(hObject,eventdata)
global vidDevice;
global hVideoIn;
redThresh = 0.15; % Threshold for red detection
vidDevice = imaq.VideoDevice('winvideo', 1, 'YUY2_640x480','ROI', [1 1 640 480],'ReturnedColorSpace', 'rgb'); % Acquire input video stream
vidInfo = imaqhwinfo(vidDevice); % Acquire input video property
hblob = vision.BlobAnalysis('AreaOutputPort', false,'CentroidOutputPort', true,'BoundingBoxOutputPort', true','MinimumBlobArea',100,'MaximumBlobArea', 3000,'MaximumCount', 10);% Set blob analysis handling
hshapeinsRedBox = vision.ShapeInserter('BorderColor', 'Custom','CustomBorderColor', [1 0 0],'Fill', true,'FillColor', 'Custom','CustomFillColor', [1 0 0],'Opacity', 0.4);% Set Red box handling
htextins = vision.TextInserter('Text', 'Distance between markings: %2d','Location', [7 2],'Color', [1 0 0],'FontSize', 20);% Set text for number of blobs
htextinsCent = vision.TextInserter('Text', '+ X:%4d, Y:%4d','LocationSource', 'Input port','Color', [1 1 0],'FontSize', 20);% set text for centroid
hVideoIn = vision.VideoPlayer('Name', 'Final Video' ,'Position', [100 100 vidInfo.MaxWidth+20 vidInfo.MaxHeight+30]);% Output video player
nFrame = 0; % Frame number initialization
breakloop =1;
%%Processing Loop
while(breakloop ==1)
rgbFrame = step(vidDevice); % Acquire single frame
rgbFrame = flipdim(rgbFrame,2); % obt ain the mirror image for displaying
diffFrame = imsubtract(rgbFrame(:,:,1), rgb2gray(rgbFrame)); % Get red component of the image
diffFrame = medfilt2(diffFrame, [3 3]); % Filter out the noise by using median filter
binFrame = im2bw(diffFrame, redThresh); % Convert the image into binary image with the red objects as white
[centroid, bbox] = step(hblob, binFrame); % Get the centroids and bounding boxes of the blobs
centroid = uint16(centroid); % Convert the centroids into Integer for further steps
rgbFrame(1:20,1:165,:) = 0; % put a black region on the output stream
vidIn = step(hshapeinsRedBox, rgbFrame, bbox); % Instert the red box
%for object = 1:1:length(bbox(:,1)) % Write the corresponding centroids
diffX =0;
diffY =0;
if uint8(length(bbox(:,1)))>= 2
centX1 = centroid(1,1);
centY1 = centroid(1,2);
centX2 = centroid(2,1);
centY2 = centroid(2,2);
%end
if centX1 > centX2
diffX =centX1-centX2;
else
diffX =centX2-centX1;
end
if centY1> centY2
diffY =centY1-centY2;
else
diffY =centY2-centY1;
end
vidIn = step(htextinsCent, vidIn, [centX1 centY1], [centX1-6 centY1-9]);
end
%vidIn = step(htextinsCent, vidIn, [centX1 centY1], [centX1-6 centY1-9]);
diffY= diffY/6.8;
diffY= uint16(diffY);
%end
vidIn = step(htextins, vidIn, diffY); % Count the number of blobs
step(hVideoIn, vidIn); % Output video stream
nFrame = nFrame+1;
end
end
%%Clearing Memory
function stopp(hObject, eventdata, handles)
global vidDevice;
global hVideoIn;
breakloop = 0;
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
release(hVideoIn); % Release all memory and buffer used
release(vidDevice);
clear all;
end
end
%

댓글을 달려면 로그인하십시오.

질문:

2018년 2월 18일

댓글:

2018년 2월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by