I want to crop a selected a rectangle area in live video feed and save those area or image in my local drive
-
I find two axis point (X1,y1) and (X2, y2) how I crop those image.
-
Hi
something with
http://doc.qt.io/qt-5/qrubberband.html
and maybe
https://doc-snapshots.qt.io/qt5-dev/qpixmap.html#copy -
You have any example
-
Hi
The docs for rubberband shows how to use it.copy just returns copy
so its just
QPixmap area=orgpix->copy ( rect from rubberband );
you can see here
https://stackoverflow.com/questions/7010611/how-can-i-crop-an-image-in-qtfor the video part , this might help
http://omg-it.works/how-to-grab-video-frames-directly-from-qcamera/#acceptLicense -
Hi
QRect rect(10, 20, 30, 40);
QPixmap original('image.png');
QPixmap cropped = original.copy(rect);
the following code is working on image how i can put video in place of image -
@robotsandi
Is it from a camera? -
i am also able to stop the camera and can i store that image in buffer to use those image.
-
@robotsandi
Ok if you already can grab images, you simply load it with full path from where you store it
or simply display it in QLabel ( as pixmap) and use rubberband to grab the area. ( or fixed in code if only needing that)
Or if you can just stop the video and it still displays last image, then directly on that. -
@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? -
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