Notes
- Returns
falseif no frame has been received yet or if the file cannot be written. - The Camera constructor already waits for the first frame, so a snapshot taken immediately after construction will succeed.
Camera:snapshot(file)method
Captures the most recently received camera frame and saves it to the specified file.
The output format is determined by the file extension. Supported formats are .png, .jpg / .jpeg, and .bmp.
Parameters
file
The destination file path as astring or a File. The file extension determines the image format (.png, .jpg, .bmp).
Return value
Returnstrue if the snapshot was saved successfully, or false if an error occurred.
Example
--! luart-extensions
import capture
local cam = capture.Camera()
if cam:snapshot("photo.png") then
print("Snapshot saved to photo.png")
else
print("Failed to save snapshot")
end