File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -72,16 +72,6 @@ ApplicationWindow {
7272
7373 Libcamera {
7474 id: libcamera
75-
76- onErrorOccurred : function (errorString ) {
77- if (state === " Libcamera" )
78- {
79- cameraSource .errorOccurred (errorString)
80- }
81- }
82- onImageCaptured : function (image ) {
83- cameraSource .imageCaptured (image)
84- }
8575 }
8676
8777 ApplicationFlow
Original file line number Diff line number Diff line change 4040 var libcameras = libcamera .availableCameras ()
4141 for (var j = 0 ; j < libcameras .length ; j++ ) {
4242 if (libcameras[j] === cameraName) {
43- libcamera .cameraName = cameraName
4443 cameraSource .state = " Libcamera"
4544 console .log (" CameraSource using Libcamera camera device: " + cameraName)
4645 return
6160 {
6261 // gphotoCamera.startCamera()
6362 }
63+ else if (state === " Libcamera" )
64+ {
65+ libcamera .startCamera (cameraName)
66+ }
6467 else
6568 {
6669 console .log (" No camera available to start!" )
7780 {
7881 // gphotoCamera.stopCamera()
7982 }
83+ else if (state === " Libcamera" )
84+ {
85+ libcamera .stopCamera ()
86+ }
8087 else
8188 {
8289 console .log (" No camera available to stop!" )
@@ -105,6 +112,24 @@ Item
105112 id: mediaDevices
106113 }
107114
115+ Connections {
116+ target: libcamera
117+ function errorOccured (errorString ) {
118+ if (state === " Libcamera" )
119+ {
120+ cameraSource .errorOccurred (errorString)
121+ }
122+ }
123+ }
124+
125+ Connections
126+ {
127+ target: libcamera
128+ function imageCaptured (image ) {
129+ cameraSource .imageCaptured (image)
130+ }
131+ }
132+
108133 GPhotoCamera {
109134 id: gphotoCamera
110135
Original file line number Diff line number Diff line change 1111using namespace libcamera ;
1212
1313LibcameraDevice::LibcameraDevice (QObject *parent)
14- : QObject (parent),
14+ : QVideoFrameInput (parent),
1515 mWorkerThread(std::make_unique<QThread>(this ))
1616{
1717 // Create worker
@@ -158,6 +158,8 @@ void LibCameraWorker::startCamera(const QString &cameraId)
158158 }
159159 mCamera = cam;
160160
161+ mCamera ->acquire ();
162+
161163 // configure camera for viewfinder role (basic example)
162164 std::unique_ptr<CameraConfiguration> config =
163165 mCamera ->generateConfiguration ({ StreamRole::Viewfinder });
Original file line number Diff line number Diff line change 44#include < QTimer>
55#include < QStringList>
66#include < memory>
7+ #include < QVideoFrameInput>
78
89#undef emit
910#undef slots
1718
1819class LibCameraWorker ;
1920
20- class LibcameraDevice : public QObject
21+ class LibcameraDevice : public QVideoFrameInput
2122{
2223 Q_OBJECT
2324public:
You can’t perform that action at this time.
0 commit comments