Skip to content

Commit 9c35d4a

Browse files
committed
app: libcamera_still: Enable optional ZSL mode
Configure the application to configure ZSL mode if the --zsh command line option is set. This keeps the stream running continuously when doing a still image capture without a reconfiguration step in between. Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
1 parent eb4c7a0 commit 9c35d4a

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

apps/libcamera_still.cpp

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ static void event_loop(LibcameraStillApp &app)
193193
std::this_thread::sleep_for(10ms);
194194
}
195195
}
196+
else if (options->zsl)
197+
app.ConfigureZsl();
196198
else
197199
app.ConfigureViewfinder();
198200
app.StartCamera();
@@ -209,6 +211,7 @@ static void event_loop(LibcameraStillApp &app)
209211
} af_wait_state = AF_WAIT_NONE;
210212
int af_wait_timeout = 0;
211213

214+
bool want_capture = false;
212215
for (unsigned int count = 0;; count++)
213216
{
214217
LibcameraApp::Msg msg = app.Wait();
@@ -235,7 +238,7 @@ static void event_loop(LibcameraStillApp &app)
235238
// In viewfinder mode, run until the timeout or keypress. When that happens,
236239
// if the "--autofocus-on-capture" option was set, trigger an AF scan and wait
237240
// for it to complete. Then switch to capture mode if an output was requested.
238-
if (app.ViewfinderStream())
241+
if (app.ViewfinderStream() && !want_capture)
239242
{
240243
LOG(2, "Viewfinder frame " << count);
241244
timelapse_frames++;
@@ -244,7 +247,6 @@ static void event_loop(LibcameraStillApp &app)
244247
bool timelapse_timed_out = options->timelapse &&
245248
(now - timelapse_time) > options->timelapse.value &&
246249
timelapse_frames >= TIMELAPSE_MIN_FRAMES;
247-
bool want_capture = false;
248250

249251
if (af_wait_state != AF_WAIT_NONE)
250252
{
@@ -281,43 +283,53 @@ static void event_loop(LibcameraStillApp &app)
281283
keypressed = false;
282284
af_wait_state = AF_WAIT_NONE;
283285
timelapse_time = std::chrono::high_resolution_clock::now();
284-
app.StopCamera();
285-
app.Teardown();
286-
app.ConfigureStill(still_flags);
286+
if (!options->zsl)
287+
{
288+
app.StopCamera();
289+
app.Teardown();
290+
app.ConfigureStill(still_flags);
291+
}
287292
if (options->af_on_capture)
288293
{
289294
libcamera::ControlList cl;
290295
cl.set(libcamera::controls::AfMode, libcamera::controls::AfModeAuto);
291296
cl.set(libcamera::controls::AfTrigger, libcamera::controls::AfTriggerCancel);
292297
app.SetControls(cl);
293298
}
294-
app.StartCamera();
299+
if (!options->zsl)
300+
app.StartCamera();
295301
}
296302
else
297303
app.ShowPreview(completed_request, app.ViewfinderStream());
298304
}
299305
// In still capture mode, save a jpeg. Go back to viewfinder if in timelapse mode,
300306
// otherwise quit.
301-
else if (app.StillStream())
307+
else if (app.StillStream() && want_capture)
302308
{
303-
app.StopCamera();
309+
want_capture = false;
310+
if (!options->zsl)
311+
app.StopCamera();
304312
LOG(1, "Still capture image received");
305313
save_images(app, completed_request);
306314
if (!options->metadata.empty())
307315
save_metadata(options, completed_request->metadata);
308316
timelapse_frames = 0;
309317
if (!options->immediate && (options->timelapse || options->signal || options->keypress))
310318
{
311-
app.Teardown();
312-
app.ConfigureViewfinder();
319+
if (!options->zsl)
320+
{
321+
app.Teardown();
322+
app.ConfigureViewfinder();
323+
}
313324
if (options->af_on_capture && options->afMode_index == -1)
314325
{
315326
libcamera::ControlList cl;
316327
cl.set(libcamera::controls::AfMode, libcamera::controls::AfModeAuto);
317328
cl.set(libcamera::controls::AfTrigger, libcamera::controls::AfTriggerCancel);
318329
app.SetControls(cl);
319330
}
320-
app.StartCamera();
331+
if (!options->zsl)
332+
app.StartCamera();
321333
af_wait_state = AF_WAIT_NONE;
322334
}
323335
else

0 commit comments

Comments
 (0)