ChromoFiber Design Tool (processing version)
ChromoFiber Design Tool (python version)
LED Locator (OpenCV version , users can observe The process of generating results)
Fiber Clibration Tool (OpenCV with PyQt5, add GUI to LED Locator)
LED stripe controller for lighting LED(Arduino version)
LED stripe controller for color changing
Color Gradient Viewer(python version)
Linear Programming solver(python version)
[TOC]
Keyboard operation(change image position and rotation) → controlled by sliders
blinking interval: 0.4s
left : original video clip
right : the detection result with opencv
output the position of each led
The method of selecting keyframes:
-
get fps from opencv and flashing period from arduino code(0.4s), flashingInterval = 0.4 * fps
-
the opencv program disposes the video clip frame by frame
-
record the frame number when the first led lights up as startFrame
-
curFrame -(curLED * flashingInterval)-startFrame < 0.5 and curFrame -(curLED * flashingInterval)-startFrame >- 0.5 :
select it !
demo video: 0710FiberCalibrationToolv1.mov
Users can select Obverse/ Reverse by clicking the button. The result will show on the corresponding window.
Users can drag the slider to control the threshold.
Press Import Video button→ choose a video from a new dialog
youtube link:https://youtu.be/ei8W3mmJWns
- deactivation with linear programing: communicate with python and get read color
- put updated color to canvas
- control fiber with processing
- double-faced (arduino, processing, python)
Successfully implement processing and Arduino communication with Serial
let processing communicate with python
This is a screenshot of processing terminal.
use scipy in python for linear programming
fiber deactivation result
When users click the “target color” button, the text on the button will turn into “Real color”. Then processing send all target colors of LEDs to python to do linear programming. The python calculates the color after deactivation and sends the data back.
Algorithm for color gradient calculation
Step 1: shoot photos ( cyan under red, green, blue light for x s)
step 2: use OpenCV to extract the data and fit the surfaces.
step3: calculate the color between the LEDs.
Color Gradient Viewer
sers can input the flashing time of a different color for each LED.
Youtube link for demo: https://youtu.be/jWNFN9iuoOI
This is the workflow of the chromo Fiber project. It contains three parts: Chromofiber Calibration Tool, Chromo Fiber Design Tool and a Linear Programming Solver.
Details for design tool and calibration tool
The position of each LED is marked with a red circle.
Color Changing
After the user clicks on the ‘Start Color Changing’ button, the LED will change according to the pattern.
change button to “Upload Scanned Video”, add position of each LED
- change single LEDs to LED stripe by interpolation
- group UI component according to the function
I merged the window into one and drew the fiber on the background image to make it more real. I tried to let the
Users only draw in the area of fiber instead of the whole canvas. It really makes the interface more intuitive! I removed all the widgets about the image. Users can also create beautiful patterns with a brush without an image.
- run FiberGUI/camera/testLed/testLed.ino to get video of LED stripe. You need to fix the camera.
- run camera/videoProess/fiberCalibrationTool.py to input video, save the ledPos.txt(can place it in the same folder of fiber_GUI.pde) and background image.
- run Fiber_GUI/fiber_GUI/solver.py to start the linear programming solver
- run Serial/testSerial/testSerial/testSerial.ino to set up Arduino and LED stripe for color changing. You need to define the data_pin according to which PIN the LED stripe is connected with ESP32.
#define DATA_PIN 7 //Pin for data on LedStrip
- in fiber_GUI, set the Serial.list[x] for Arduino. If you just want to test the design tool, you can set it to a number less than the length of Serial.list(). You can see the name of Serial in the result printed by printArray(Serial.list())
OpenCV to capture the flash of light. I used it to get 233 photos in a video of a cyan fiber being illuminated with blue light. You need to change the parameters before running the code
I added a button to select between “Color Picker Mode” and “Color Wheel Mode”, users can choose black, white, cyan, yellow for the brush color.
![截屏2022-09-13 下午7.13.20](README.assets/截屏2022-09-13 下午7.13.20.png)
I put the new deactivation data in to linear programming solver and test the preview result.
inf= 1000000 FULL_DEACTIVATION_TIME = [[3500,2000,3600],[2000,2000,1000],[inf,4500,60]]
The red color can not be simulated well by our fiber. The green and blue colors can be simulated well.
Currently, there is no constrains on the LED shining time. We can add more constrains to the solver to see the results.
- Change LED shape from rectangle to hexagon
- Add the Image back and the sliders
- Initialize the fiber with a given shape rather than load LED positions.
- Disable the color picker mode
After testing the rainbow image, it was found that the maximum time for all colors is 327s. Therefore, I set the maximum color-changing time to 350s.
add a checkbox and a slider to set the max time
# Pure Cyan: RGB(182,168, 249)
# Pure Magenta:RGB(237, 117,140)
# Pure Yellow: RBG(250, 223, 87)
def standardCMY_to_ourCMY(c,m,y,k):
pureCyan = rgb_to_cmyk(182,168, 249)
pureMagenta = rgb_to_cmyk(237, 117,140)
pureYellow = rgb_to_cmyk(250, 223, 87)
resC = c* (pureCyan[0] + pureMagenta[0] + pureYellow[0])
resM = m* (pureCyan[1] + pureMagenta[1] + pureYellow[1])
resY = y* (pureCyan[2] + pureMagenta[2] + pureYellow[2])
resK = k* (pureCyan[3] + pureMagenta[3] + pureYellow[3])
return resC, resM, resY, resK