如果检测到 blob,则弹出消息,MATLAB
Pop up message if blob is detected, MATLAB
我正在 MATLAB 中开发一个火灾探测程序,其中有一个斑点检测。我想问一下如何在检测到斑点时弹出警告消息?
我想在发生火灾时立即收到警告消息。
这是我的形状插入器或斑点检测框的代码。
这部分在循环外:
detector = vision.ForegroundDetector(...
'NumTrainingFrames', 5, ...
'InitialVariance' , 30*30);
blob = vision.BlobAnalysis(...
'CentroidOutputPort', false, 'AreaOutputPort', false, ...
'BoundingBoxOutputPort', true, ...
'MinimumBlobAreaSource', 'Property', 'MinimumBlobArea', 250);
shapeInserter = vision.ShapeInserter('BorderColor', 'White');
videoPlayer = vision.VideoPlayer();
这部分在循环内:
fgMask = step(detector, maskedRGBImage);
bbox = step(blob, fgMask);
out = step(shapeInserter, thisFrame, bbox);
step(videoPlayer, out);
对于此示例,我假设如果检测到斑点,它将等于 1(您可以更改我的代码以适应检测到斑点时当前的任何输出)。
if blob == 1;
inputOptions = {'Fire Detected!'};
defSelection = inputOptions{1};
popup = bttnChoiseDialog(inputOptions, 'Warning!', defSelection, 'Warning!');
fprintf( 'Fire Detected - "%s"\n',inputOptions{popup});
else
continue
end
您可以从 FileExchange 下载 bttnChoiseDialog
:http://www.mathworks.com/matlabcentral/fileexchange/37261-generalised-question-dialog--questdlg-/content/BtnChoiseDlg/bttnChoiseDialog.m
希望这对您有所帮助
我正在 MATLAB 中开发一个火灾探测程序,其中有一个斑点检测。我想问一下如何在检测到斑点时弹出警告消息?
我想在发生火灾时立即收到警告消息。
这是我的形状插入器或斑点检测框的代码。
这部分在循环外:
detector = vision.ForegroundDetector(...
'NumTrainingFrames', 5, ...
'InitialVariance' , 30*30);
blob = vision.BlobAnalysis(...
'CentroidOutputPort', false, 'AreaOutputPort', false, ...
'BoundingBoxOutputPort', true, ...
'MinimumBlobAreaSource', 'Property', 'MinimumBlobArea', 250);
shapeInserter = vision.ShapeInserter('BorderColor', 'White');
videoPlayer = vision.VideoPlayer();
这部分在循环内:
fgMask = step(detector, maskedRGBImage);
bbox = step(blob, fgMask);
out = step(shapeInserter, thisFrame, bbox);
step(videoPlayer, out);
对于此示例,我假设如果检测到斑点,它将等于 1(您可以更改我的代码以适应检测到斑点时当前的任何输出)。
if blob == 1;
inputOptions = {'Fire Detected!'};
defSelection = inputOptions{1};
popup = bttnChoiseDialog(inputOptions, 'Warning!', defSelection, 'Warning!');
fprintf( 'Fire Detected - "%s"\n',inputOptions{popup});
else
continue
end
您可以从 FileExchange 下载 bttnChoiseDialog
:http://www.mathworks.com/matlabcentral/fileexchange/37261-generalised-question-dialog--questdlg-/content/BtnChoiseDlg/bttnChoiseDialog.m
希望这对您有所帮助