# Performance Analysis of a Color-Code-Based Optical Camera Communication System
## 2 Proposed OCC System Architecture
### Receiver Design  
The cell phone used as a receiver was connected to a USB keyboard for easy code writing. The Pydroid compiler was installed on the receiver phone. Python and Tkinter are installed in the Pydroid compiler. Although Python offers many libraries for image processing, the OpenCV library was used in this study. Since OpenCV cannot be used directly in computer applications, Tkinter was needed. The main camera of the phone, called number 1, and the front camera, can be used by OpenCV. Since it is not authorized to access the other 3 cameras, only the main camera was used in this study.  
After the application is run, the camera starts taking images within the specified time. The image is zoomed in depending on the distance of the transmitter. The frequency of image acquisition is synchronized to the transmission speed of the transmitter. After the starting data are received, each image is recorded. After the image acquisition process is completed, the decoding stage is started with image processing. At this stage, various algorithms and modules are applied to prevent distortions with image processing techniques. The data are converted into messages by making the desired improvements. Here, the entire image from the camera is not processed. In Canvas, only the section with the channels is processed by cropping and resizing, and pixel color values are written to Canvas. Since Pydroid does not offer terminal options for applications, in this study, a terminal was created in the Python language on Canvas. The flow chart summarizing the working principle of the program running on the mobile phone is shown in Figure 5.  
The OpenCV code block needed for the camera to capture images is shown in Figure 6. The time.sleep (second) and cnvs.after (millisecond, capture) commands written in the Pydroid compiler specify the delay time of the receiver.  
Canvas and Label tags were used to display the image on the screen. Figure 7 shows the code sections of the software used for Canvas. Since Canvas was chosen as the serial monitor, Canvas was also chosen for displaying the image on the screen. In the communication system, the character string \"Li-Fi+Test-\" was selected as sample data. The monitor at the transmitter displays this character string at the specified time interval. The camera at the receiver is continuously searching for the start data.  
When the starting data are received, images are taken within the specified time and saved in a list type array named \"frame_x\". Problems that occur on the receiver side during communication are logged in an array named \"exc:\", which Python provides for error conditions. The message to be written to Canvas for the camera capture problem is \"camera can't get a picture\". The serial monitor monitors whether the data are received correctly according to parameters such as contrast, color brightness, ambient light, channel size, color depth, distance, etc.  
Figure 4: Coordinates of color channels (transmitter).  
Figure 5: Flow chart for the receiver.  
Figure 6: Capturing images in OpenCV.