From f461b8c587ea246ac3f85aae662fb1672a263a09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9tro?= <yann.roberge@polymtl.ca> Date: Tue, 25 May 2021 10:08:43 -0400 Subject: [PATCH] Temp --- main.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index f96f461..0b3b613 100644 --- a/main.c +++ b/main.c @@ -6,10 +6,26 @@ #include "main.h" #include "rgb2hsv.h" + #include <stdio.h> +#include <stdint.h> + +// Load raw image to memory. Images should be in +int loadFrameFromDisk(const uint8_t* frameBuffer, int index) { + char filepath[100]; + sprintf(filepath, "FRAME_IN_DIRECTORY/FRAME_IN_FILENAME%d", index); + int fd = open(filepath); + return read(fd, (void*) frameBuffer, FRAME_BUF_SIZE); +} -// Load raw image to memory +int writeFrameToDisk(const uint8_t* frameBuffer, int index) { + char filepath[100]; + sprintf(filepath, "FRAME_OUT_DIRECTORY/FRAME_OUT_FILENAME%d", index); + int fd = open(filepath); + return write(fd, (void*) frameBuffer, FRAME_BUF_SIZE); +} +correctPixelColor // Convert to HSV // Add corrections @@ -18,7 +34,23 @@ // Pass hue, saturation and value (lightness / 2) corrections to args int main(int argc, char* argv) { - printf("%d\n", argc); + // Start timing + const uint8_t frameBuffer[FRAME_BUF_SIZE]; + int i, j; + for (i=0; i<N_IMAGES; i++) { + loadFrameFromDisk(frameBuffer, i); + + // Apply correction to each pixel and write it back to the frame buffer + for (j=0; j<FRAME_BUF_SIZE; j+=3) { + correctPixelColor(frameBuffer[j], DELTA_HUE, + DELTA_SATURATION, DELTA_VALUE); + } + + writeFrameToDisk(frameBuffer, i); + } + + // Stop timing + printf("Done.\n"); return 0; } -- GitLab