Example of interacting with the camera through native extensions.
Although we aim to provide good example functionality in this example, we cannot guarantee the quality/stability at all times. Please regard it as just that, an example, and don't rely on this as a dependency for your production code.
The currently supported platforms are: OSX + iOS
Add the package link (https://github.com/defold/extension-camera/archive/master.zip)
to the project setting project.dependencies
, and you should be good to go.
See the manual for further info.
Describes what camera should be used
camera.CAMERA_TYPE_FRONT -- Selfie
camera.CAMERA_TYPE_BACK
camera.CAPTURE_QUALITY_HIGH
camera.CAPTURE_QUALITY_MEDIUM
camera.CAPTURE_QUALITY_LOW
Returns true if the capture starts well
if camera.start_capture(camera.CAMERA_TYPE_BACK, camera.CAPTURE_QUALITY_HIGH) then
-- do stuff
end
Stops a previously started capture session
Gets the info from the current capture session
local info = camera.get_info()
print("width", info.width)
print("height", info.height)
Retrieves the camera pixel buffer This buffer has one stream named "rgb", and is of type buffer.VALUE_TYPE_UINT8 and has the value count of 1
self.cameraframe = camera.get_frame()