ImageCapture QML Type
Un'interfaccia per l'acquisizione delle immagini della telecamera. Altro...
| Import Statement: | import QtMultimedia |
Proprietà
- error : enumeration
- errorString : string
- fileFormat : enumeration
- metaData : mediaMetaData
- preview : string
- quality : enumeration
- readyForCapture : bool
- supportedFormats : list<FileFormat>
(since 6.10)
Segnali
- errorOccurred(id, error, errorString)
- imageCaptured(requestId, preview)
- imageMetadataAvailable(id, metaData)
- imageSaved(id, fileName)
Metodi
- int capture()
- int captureToFile(location)
- void saveToFile(location)
Descrizione dettagliata
Questo tipo consente di acquisire immagini fisse e di ricevere una notifica quando sono disponibili o vengono salvate su disco.
Item {
width: 640
height: 360
CaptureSession {
imageCapture : ImageCapture {
id: imageCapture
}
camera: Camera {
id: camera
}
videoOutput: videoOutput
}
VideoOutput {
id: videoOutput
anchors.fill: parent
MouseArea {
anchors.fill: parent;
onClicked: imageCapture.capture();
}
}
Image {
id: photoPreview
source: imageCapture.preview // always shows the last captured image
}
}Documentazione delle proprietà
error : enumeration [read-only]
Questa proprietà contiene il tipo dell'ultimo errore verificatosi. Può assumere uno dei seguenti valori.
| Costante | Descrizione |
|---|---|
ImageCapture.NoError | Nessun errore. |
ImageCapture.NotReadyError | Il servizio non è ancora pronto per l'acquisizione. |
ImageCapture.ResourceError | Il dispositivo non è pronto o non è disponibile. |
ImageCapture.OutOfSpaceError | Non c'è più spazio sul dispositivo. |
ImageCapture.NotSupportedFeatureError | Il dispositivo non supporta l'acquisizione di immagini fisse. |
ImageCapture.FormatError | Il formato corrente non è supportato. |
Vedi anche errorString.
errorString : string [read-only]
Questa proprietà contiene l'ultimo messaggio di errore verificatosi.
Vedi anche error.
fileFormat : enumeration
Questa proprietà indica il formato file in cui verrà salvata l'immagine. Può assumere uno dei seguenti valori.
| Costante | Descrizione |
|---|---|
UnspecifiedFormat | Nessun formato specificato |
JPEG | .jpg o formato " .jpeg " |
PNG | .png formato |
WebP | .webp formato |
Tiff | .tiff formato |
metaData : mediaMetaData
Questa proprietà contiene i metadati che verranno incorporati nell'immagine.
preview : string [read-only]
Questa proprietà contiene l'URL dell'ultima immagine acquisita. Può essere collegata alla proprietà "source" di un elemento Image per visualizzare l'ultima immagine acquisita.
CaptureSession {
camera: Camera {}
imageCapture: ImageCapture {
id: capture
}
}
Image {
source: capture.preview
}Vedi anche saveToFile.
quality : enumeration
Questa proprietà contiene l'indicazione di qualità al momento della memorizzazione dell'immagine acquisita. Può assumere uno dei seguenti valori.
| Costante | Descrizione |
|---|---|
VeryLowQuality | Molto bassa |
LowQuality | Bassa |
NormalQuality | Normale |
HighQuality | Alto |
VeryHighQuality | Molto alto |
readyForCapture : bool [read-only]
Questa proprietà contiene un valore booleano che indica se la fotocamera è pronta a scattare foto o meno.
La chiamata a ` capture()` o ` captureToFile()` quando la fotocamera è pronta o si trov false e non è consentita e genera un errore.
supportedFormats : list<FileFormat> [read-only, since 6.10]
Contiene un elenco dei formati di file supportati.
Questa proprietà è stata introdotta in Qt 6.10.
Vedi anche fileFormat.
Documentazione sui segnali
errorOccurred(id, error, errorString)
Questo segnale viene emesso quando si verifica un errore durante l'acquisizione con l'id richiesto. error è un'enumerazione di tipo ImageCapture::Error. Un messaggio descrittivo è disponibile in errorString.
Nota: il gestore corrispondente è onErrorOccurred.
Vedi anche error e errorString.
imageCaptured(requestId, preview)
Questo segnale viene emesso quando un'immagine con l'ID richiesto requestId è stata acquisita ma non è stata ancora salvata nel filesystem. Il parametro preview rappresenta l'immagine acquisita.
Nota: il gestore corrispondente è onImageCaptured.
Vedi anche imageSaved e preview.
imageMetadataAvailable(id, metaData)
Questo segnale viene emesso quando l'immagine con l'id richiesto presenta un nuovo metaData.
Nota: il gestore corrispondente è onImageMetadataAvailable.
Vedi anche imageCaptured.
imageSaved(id, fileName)
Questo segnale viene emesso dopo che l'immagine con l'id richiesto è stata scritta nel filesystem. L'fileName è un percorso di file locale, non un URL.
Nota: il gestore corrispondente è onImageSaved.
Vedi anche imageCaptured.
Documentazione del metodo
int capture()
Avvia l'acquisizione dell'immagine. Al termine dell'acquisizione verranno emessi i segnali imageCaptured e imageSaved.
L'immagine acquisita sarà disponibile tramite la proprietà "preview", che può essere utilizzata come sorgente per un elemento Image in QML. È quindi possibile utilizzare il metodo saveToFile() per salvare l'immagine.
La fotocamera salva tutti i parametri di acquisizione, come le impostazioni di esposizione o i parametri di elaborazione dell’immagine; pertanto, le modifiche ai parametri della fotocamera effettuate dopo la chiamata a `capture()` non influiscono sulle richieste di acquisizione precedenti.
`capture()` restituisce il parametro `requestId` della cattura, utilizzato con i segnali `imageExposed()`, ` imageCaptured()`, ` imageMetadataAvailable()` e ` imageSaved()`.
Vedi anche readyForCapture e preview.
int captureToFile(location)
Esegue la stessa operazione di ` capture()` ma, in più, salva automaticamente l'immagine acquisita nel file specificato ` location`. Restituisce il parametro `requestId` dell'acquisizione.
Vedi anche capture().
void saveToFile(location)
Salva l'ultima immagine acquisita in location.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.