Unsolved I want to crop a selected a rectangle area in live video feed and save those area or image in my local drive
-
@mrjj
yes, i just stop the video and it still displays the last image,
but how can i directly itvoid MainWindow::on_pushButton_clicked()
{
mCamera->setViewfinder(mCameraViewfinder);
mLayout->addWidget(mCameraViewfinder);
mLayout->setMargin(0);
ui->scrollArea->setLayout(mLayout);
mCamera->start();
}void MainWindow::on_pushButton_2_clicked()
{
mCamera->stop();
} -
@mrjj Plese help me.
-
@robotsandi
well i dont know for sure.
I think you have to use a
http://doc.qt.io/qt-5/qcameraimagecapture.html#details
to get an image.
But why not just copy from what ever is on screen ?
Do you also need image first? -
@mrjj
mCamera->setCaptureMode(QCameraImageCapture::CaptureToBuffer);
how to stope image to use this code -
Hi
I think you just connect image capture to it
imageCapture = new QCameraImageCapture(camera);
and hook up to
http://doc.qt.io/qt-5/qcameraimagecapture.html#imageCaptured
to get signal and image when its ready -
Hi
maybe this sample is good start ?
http://doc.qt.io/qt-5/qtmultimedia-multimediawidgets-camera-example.htmlIt can grab photo.
-
@mrjj
Hi
I have 4 coordinate (x1, y1, x2, y2)
(x1, y1) is for press mouse button or (x2, y2) for release mouse button
how can i fine height and weight.
please, can you explain me: -
@robotsandi
Well you can just cheat
QRect area( x1,y1,x2,y2 ) ;
( or as QPoint if you have that QRect area( p1, p2 ) )
then you can just ask itarea.width()
area.height()else its
int w= x2 - x1;
int h=y2-y1; -
@mrjj
How to save image
int width = x2-x1;
int height = y2-y1;
QPixmap original("mCameraImageCapture");
//QPixmap cropped = original.copy(rect);
QPixmap cropped = original.copy(x1, y1, width, height); -
@robotsandi
mCameraImageCapture->setCaptureDestination(QCameraImageCapture::CaptureToBuffer);
QImageEncoderSettings imageEncoderSettings;
imageEncoderSettings.setCodec("imag/jpeg");
imageEncoderSettings.setResolution(1600,1200);
mCameraImageCapture->setEncodingSettings(imageEncoderSettings); -
.setCodec("imag/jpeg");
Is that correct?
Seems to miss an e -
@mrjj
yes this is correct -
@robotsandi
Is that correct
mCameraImageCapture->setCaptureDestination(QCameraImageCapture::CaptureToBuffer);
to mCameraImage Capture is store image in buffer?? -
@robotsandi
QPixmap original("mCameraImageCapture");
QPixmap cropped = original.copy(x1, y1, width, height);
cropped.save(filename);
is pic is not save -
Yes it think its ok.
But not used in sample so might not be needed.
They just setup
imageCapture = new QCameraImageCapture(camera);
and hook up signal
connect(imageCapture, &QCameraImageCapture::imageCaptured, this, &Camera::processCapturedImage);
and then dovoid Camera::processCapturedImage(int requestId, const QImage& img) { Q_UNUSED(requestId); QImage scaledImage = img.scaled(ui->viewfinder->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); ui->lastImagePreviewLabel->setPixmap(QPixmap::fromImage(scaledImage)); // Display captured image for 4 seconds. displayCapturedImage(); QTimer::singleShot(4000, this, &Camera::displayViewfinder); }