我试图在两个QLabel小部件上显示一个摄像头输出。但是我无法这样做。我遇到以下错误。
Graph failed to connect filters -2147024809
但是我可以在一个屏幕上看到它而不是另一个屏幕。如果这是一种错误的方法,或者根本不可能?
cM = new QCamera(this);
cM2 = new QCamera(this);
cV = new QCameraViewfinder(this);
cV2 = new QCameraViewfinder(this);
mMenu = new QMenu("Options",this);
cA = new QAction("one camera", this);
cA2 = new QAction("both camera", this);
mMenu->addActions({cA, cA2});
ui->pushButton->setMenu(mMenu);
cM->setViewfinder(cV);
cM2->setViewfinder(cV2);
cBox1 = new QVBoxLayout();
cBox2 = new QVBoxLayout();
cBox1->addWidget(cV);
cBox2->addWidget(cV2);
ui->label->setLayout(cBox1);
ui->label_2->setLayout(cBox2);
connect(cA, &QAction::triggered, [&](){
cM->start();
cM2->start();
答案 0 :(得分:0)
您需要使用cameraInfo构建yoru相机,否则它不会绑定到真实硬件。 https://doc.qt.io/qt-5/qcamera.html
% generate example image
bw = im2double(rgb2gray(imread('example.jpg'))) == 1;
% dilate binary object to overlap watershed boundaries
bwDil = imdilate(bw,ones(5));
% get watershed labels
D = bwdist(bw);
D = -D;
D(bw) = -Inf;
L = watershed(D);
% get binary regions and remove fg object
R = (L > 0);
R(bw) = 0;
% get boundaries of all regions
BR = bwboundaries(R);
% set boundary ratio - if a regio's shares more boundary with fg object
% than this threshold it considered surrounded
boundaryRatio = zeros(numel(BR),1);
ratioThresh = 0.6;
mask = false(size(bw));
% go through region boundaries and add them to mask if above tresh
for ii = 1:numel(BR)
ind = sub2ind(size(bw),BR{ii}(:,1),BR{ii}(:,2));
boundaryRatio(ii) = nnz(bwDil(ind))/numel(ind);
if boundaryRatio(ii) > ratioThresh
mask(ind) = 1;
end
end
% fill mask
mask = imfill(mask,4,'holes');
% plot
subplot(121);
imshow(bw);
title('fg')
rgb = double(cat(3,mask,bw,bw));
subplot(122);
imshow(rgb);
title('fg with surrounded bg')