1

Part of an application I have written has the ability to capture pictures from the webcam. I am using a QCamera with a QCameraViewfinder to display the current view, and then when a shutter button is clicked, it snaps a picture with a QCameraImageCapture set to capture to buffer, then handles it from there. I have just discovered that it is also saving a copy of the image in the local Pictures folder. Why is this happening, and how can I stop it?

SaintWacko
  • 854
  • 3
  • 14
  • 35
  • 1
    Sorry for joining late but I was just dealing with this today. I didn't find any clean way but I noticed giving a file name and path to QImageCapture::capture() that is to a nonexistent path, nothing seems to happen. Apparently, it won't create the directory and the file open fails. Not the happiest choice but keeps lots of images from piling up. Another thing I tried was writing the same file name every time. Then there's just one imaged that needs to be cleaned up. – Tim Craig Jun 24 '18 at 05:15

2 Answers2

2

This is just my point of observation:

Based on the documentation, after you call capture, irrespective of destination location ( I mean CaptureToFile or CaptureToBuffer) the image is saved to a file.

note this statemet in below link: If an empty file is passed, the camera backend choses the default location and naming scheme for photos on the system.

http://doc.qt.io/qt-5/qcameraimagecapture.html#capture

The additional advantage with "CaptureToBuffer", your image is saved in some specified buffer format.

My wild guess, if at all they are not supporting ( as i am unable to find any offical information on it) only capture to buffer, the reason could be,

the user is allowed to set the bufferformat using setBufferFormat. And the device may not support the buffer format (isCaptureDestinationSupported() is there to check it.). May be because of this they are saving to local pictures folder always.

If this saving is unavoidable by capture, and if your business strictly needs not to maintain those saved files, when your buffer is doing good, probably you can delete them in below slot.

QObject::connect(YOURCAMERACAPTUREOBJECT, SIGNAL(imageSaved), this,SLOT(saved(int id, const QString &fileName)));

void saved(int id, const QString &fileName)
{

//Delete the file by checking you have content in buffer.
//to check the buffer probably you can use "imageAvailable" signal

}
Pavan Chandaka
  • 11,671
  • 5
  • 26
  • 34
0

I believe that bug you are describing were in GStreamer camerabin plugin. When you look to https://code.qt.io/cgit/qt/qtmultimedia.git/tree/src/plugins/gstreamer/camerabin/camerabinsession.cpp?h=5.15#n587 m_imageFileName is setup independently on capture destination. File is saved by this filter then https://code.qt.io/cgit/qt/qtmultimedia.git/tree/src/plugins/gstreamer/mediacapture/qgstreamercapturesession.cpp?h=5.15#n404

edit: This bug seems to be fixed somehow in Qt 5.15.

Karry
  • 381
  • 3
  • 4