I want to crop a selected a rectangle area in live video feed and save those area or image in my local drive
-
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.
-
@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; -
@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 -
@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); }