Luxometer is a Swift library that uses iPhone camera to measure ambient light illuminance in lux.
Use the Swift Package Manager to install Luxometer:
- In Xcode go to File ‣ Add Packages
- Enter https://github.com/Basistiy/Luxometer in the search field.
Luxometer uses iPhone cameras so you need to add "Privacy - Camera Usage Description" description to the Info.plist file of your project.
import Luxometer
let luxometer = Luxometer()
luxometer.capturedIlluminance = {value in
//The value is equal to ambient light illuminance in lux. The value is output 30 times a second.
}
luxometer.changeCamera()
The output lux value is calibrated for iPhone 12 mini front camera by default. Calibration for other devices is required. Change luxometer.calibrationConstant to adjust output illuminance value.
Pull requests are welcome.