Skip to content

ferdinandgit/CamFitzpatrick

Repository files navigation

CamFitzpatrick


This project determine your phototype with the help of a macro camera.

Features

  • Camera Calibration with references colors samples.
  • Phototye estimation with Fitzpatrick Scale.

Tech

CameFitzpatrick uses a number python open source projects to work properly:

  • [OpenCV] - Python library used for computer vision.
  • [csv] - Python csv editor.
  • [numpy] - Python math extension.
  • [scipy] - SciPy provides algorithms for o{:.centered}.
  • [keyboard] - Hook global events, register hotkeys, simulate key presses and much more.

Installation

This project requires Python v3.11.0+ to run.

Start python virtual environement installation script
for linux users:

./linuxvenv.sh

for windows users:

.\winvenv.bat 

Camera Calibration

In order to calibrate your camera you need this kind of color samples. You can use other colors samples as long as they are not printed otherwise the calibration will not be efficient. Painted samples will be preferred.

Pantone SkinTone Guide Pantone The Plus Series

Before running any code make shure that your video input is the rigth one in each python script.

videoinput=2 #find the number that is associated with your video device 
srelease=False
nbscannedcolors=0

Then in order to start calibration run for linux users:

sudo startcalibration.sh 

for windows users:

startcalibration.bat

There is 2 keys to control the script:

  • S key is used to estimate and save the avrage color in the green rectangle.
  • Q key is used to kill the script.

In order to start measurement, adjust your camera position to make the square above the reference color and press S to save the color and enter the RGB value of your reference in the text box. .

The script is outpouting a csv file with 6 rows, 3 rows for the RGB refenrence color value, 3 rows for the RGB mesured color value.

Thus we can determine 3 simples functions that give the correction factor for each RGB pixel components knowing the mesured RGB value of the pixel. Let's consider equation the corrective factor, each functions is declared like:

equation

With all collected samples we can determine the equation for each pixel using a scipy first degree interpolation

equation equation equation

Skin Tone determination

Make shure that the calibration csv file path is the good one in the python script

with open('calibration.csv', newline='') as csvfile: #Change your file path here 
    reader = csv.DictReader(csvfile)
    for row in reader:

In order to start skin Tone determination run:

for linux users:

sudo startskintone.py 

for windows users:

startskintone.bat

There is 2 keys to control the script:

  • P key is used to estimate the skin tone.
  • Q key is used to kill the script.

Adjust your camera position to make the square above the skin. Once P is pressed a second windows open and display the corrected image and the skin tone estimation is displayed in the left top corner of the main window.

Appendix

I used this Camera to test each of my scripts, few camera brackets 3D files are also avaliable on the repo.

About

Evaluate skin fitzpatrick with macro camera

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published