<commit_before>/* client.c*/
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "config.h"
#include "if.h"
#include "net.h"

static const char *progname;

static void warn(const char *format, ...)
{
	va_list ap;

	fputs(progname, stderr);
	fputs(": ", stderr);
	va_start(ap, format);
	vfprintf(stderr, format, ap);
	va_end(ap);
	fputs("\n", stderr);
}

static void sendframe(const if_frame *frame)
{
	void *buf;
	size_t n;

	if (!(buf = if_fpack(frame, &n))) {
		warn("unable to convert local frame");
		return;
	}
	net_send(buf, n);
	free(buf);
}

static if_frame *recvframe(int *status)
{
	if_frame *r;
	void *buf;
	size_t n;

	if (!(buf = net_recv(status, &n)))
		return 0;
	if (!(r = if_funpack(buf, n)))
		warn("unable to convert remote frame");
	free(buf);
	return r;
}

struct ldata {
	if_cam *cam;
	if_window *wremote;
	if_window *wlocal;
	if_frame *fpending;
	if_frame *fnc;
	if_mat *curr_img; /* Create the 2 comperative images*/
	if_mat *prev_img;
};

static int init(struct ldata *lp)
{
	if (!(lp->wremote = if_winit(RWINDOWNAME, FRAMEWIDTH, FRAMEHEIGHT))) {
		warn("unable to initialise remote display");
		return -1;
	}
	if (!(lp->wlocal = if_winit(LWINDOWNAME, FRAMEWIDTH, FRAMEHEIGHT))) {
		warn("unable to initialise local display");
		return -1;
	}
	if (!(lp->cam = if_caminit())) {
		warn("unable to initialise camera");
		return -1;
	}
	if (!(lp->fpending = if_fload(IMAGE_PATH PENDING_FILE)))
		warn("unable to load image: %s\n", PENDING_FILE);
	if (!(lp->fnc = if_fload(IMAGE_PATH NO_CONNECT_FILE)))
		warn("unable to load image: %s\n", NO_CONNECT_FILE);
	if(!(lp->curr_img = cvCreateMat(lp->fnc->height, lp->fnc->width, CV_8UC1)) ||
			!(lp->prev_img = cvCreateMat(lp->curr_img->rows, lp->curr_img->cols, lp->curr_img->type)))
	{
		/* Create matrices for image comparison*/
		warn("Can not create Matrices");
		return -1;
	}
	return 0;
}

static void cleanup(struct ldata *lp)
{
	if (lp->fnc)
		if_frelease(lp->fnc);
	if (lp->fpending)
		if_frelease(lp->fpending);
	if (lp->cam)
		if_camrelease(lp->cam);
	if (lp->wremote)
		if_wfree(lp->wremote);
	if (lp->wlocal)
		if_wfree(lp->wlocal);
	if(lp->curr_img)
		if_wfree(lp->curr_img);
	if(lp->prev_img)
		if_wfree(lp->prev_img);
}

static int mainloop(struct ldata *lp)
{
	if_wrender(lp->wremote, lp->fnc);
	do {
		clock_t ms = clock();
		if_frame *f;<commit_msg>Comparison frame added<commit_after>/* client.c*/
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "config.h"
#include "if.h"
#include "net.h"

static const char *progname;

static void warn(const char *format, ...)
{
	va_list ap;

	fputs(progname, stderr);
	fputs(": ", stderr);
	va_start(ap, format);
	vfprintf(stderr, format, ap);
	va_end(ap);
	fputs("\n", stderr);
}

static void sendframe(const if_frame *frame)
{
	void *buf;
	size_t n;

	if (!(buf = if_fpack(frame, &n))) {
		warn("unable to convert local frame");
		return;
	}
	net_send(buf, n);
	free(buf);
}

static if_frame *recvframe(int *status)
{
	if_frame *r;
	void *buf;
	size_t n;

	if (!(buf = net_recv(status, &n)))
		return 0;
	if (!(r = if_funpack(buf, n)))
		warn("unable to convert remote frame");
	free(buf);
	return r;
}

struct ldata {
	if_cam *cam;
	if_window *wremote;
	if_window *wlocal;
	if_window *wdetect;
	if_frame *fpending;
	if_frame *fnc;
	if_frame *detect;
	if_mat *curr_img; /* Create the 2 comperative images*/
	if_mat *prev_img;
};

static int init(struct ldata *lp)
{
	if (!(lp->wremote = if_winit(RWINDOWNAME, FRAMEWIDTH, FRAMEHEIGHT))) {
		warn("unable to initialise remote display");
		return -1;
	}
	if (!(lp->wlocal = if_winit(LWINDOWNAME, FRAMEWIDTH, FRAMEHEIGHT))) {
		warn("unable to initialise local display");
		return -1;
	}
	if (!(lp->wdetect = if_winit(DWINDOWNAME, FRAMEWIDTH, FRAMEHEIGHT))) {
		warn("unable to initialise local display");
		return -1;
	}
	if (!(lp->cam = if_caminit())) {
		warn("unable to initialise camera");
		return -1;
	}
	if (!(lp->fpending = if_fload(IMAGE_PATH PENDING_FILE)))
		warn("unable to load image: %s\n", PENDING_FILE);
	if (!(lp->fnc = if_fload(IMAGE_PATH NO_CONNECT_FILE)))
		warn("unable to load image: %s\n", NO_CONNECT_FILE);
		
	if(!(lp->curr_img = cvCreateMat(lp->fnc->height, lp->fnc->width, CV_8UC1)) ||
			!(lp->prev_img = cvCreateMat(lp->curr_img->rows, lp->curr_img->cols, lp->curr_img->type)))
	{
		/* Create matrices for image comparison*/
		warn("Can not create Matrices");
		return -1;
	}
	return 0;
}

static void cleanup(struct ldata *lp)
{
	if (lp->fnc)
		if_frelease(lp->fnc);
	if (lp->fpending)
		if_frelease(lp->fpending);
	if(lp->detect)
		if_frelease(lp->detect);
	if (lp->cam)
		if_camrelease(lp->cam);
	if (lp->wremote)
		if_wfree(lp->wremote);
	if (lp->wlocal)
		if_wfree(lp->wlocal);
	if(lp->wdetect)
		if_wfree(lp->wdetect);
	if(lp->curr_img)
		if_mfree(lp->curr_img);
	if(lp->prev_img)
		if_mfree(lp->prev_img);
}

static int mainloop(struct ldata *lp)
{
	if_wrender(lp->wremote, lp->fnc);
	do {
		clock_t ms = clock();
		if_frame *f;
{'fraction_non_alphanumeric': 0.17668197244959075, 'fraction_numerical': 0.003793172289878219, 'mean_word_length': 4.4874041621029575, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 82, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2778503', 'n_tokens_mistral': 2179, 'n_tokens_neox': 2091, 'n_words': 473}