<commit_before>package main

import (
	cv "github.com/lazywei/go-opencv/opencv"

	"bytes"
	"encoding/base64"
	"encoding/json"
	"image/jpeg"
	"io/ioutil"
	"net/http"
	"time"
)

var (
	cam0 *cv.Capture
)

type imageData struct {
	Key   string `json:"key"`
	Image string `json:"image"`
}

func init() {
	cam0 = cv.NewCameraCapture(0)
	if cam0 == nil {
		if DEBUG {
			Log.Debug("can not open camera")
			return
		}
		Log.Fatal("can not open camera")
	}
}

func captureAndPost() {
	for {
		time.Sleep(CAMERA_INTERVAL)

		if !cam0.GrabFrame() {
			continue
		}

		//!!!DO NOT RELEASE or MODIFY the retrieved frame!!!
		img := cam0.RetrieveFrame(1)
		if img == nil {
			Log.Error("failed to capture")
			continue
		}

		buf := new(bytes.Buffer)
		err := jpeg.Encode(buf, img.ToImage(), nil)
		if err != nil {
			Log.Error(err.Error())<commit_msg>[MOD] separate camera device setting<commit_after>package main

import (
	cv "github.com/lazywei/go-opencv/opencv"

	"bytes"
	"encoding/base64"
	"encoding/json"
	"image/jpeg"
	"io/ioutil"
	"net/http"
	"time"
)

var (
	cam0 *cv.Capture
)

type imageData struct {
	Key   string `json:"key"`
	Image string `json:"image"`
}

func init() {
	cam0 = cv.NewCameraCapture(CAM0_DEVICE)
	if cam0 == nil {
		if DEBUG {
			Log.Debug("can not open camera")
			return
		}
		Log.Fatal("can not open camera")
	}
}

func captureAndPost() {
	for {
		time.Sleep(CAMERA_INTERVAL)

		if !cam0.GrabFrame() {
			continue
		}

		//!!!DO NOT RELEASE or MODIFY the retrieved frame!!!
		img := cam0.RetrieveFrame(1)
		if img == nil {
			Log.Error("failed to capture")
			continue
		}

		buf := new(bytes.Buffer)
		err := jpeg.Encode(buf, img.ToImage(), nil)
		if err != nil {
			Log.Error(err.Error())
{'fraction_non_alphanumeric': 0.15294804436660828, 'fraction_numerical': 0.010507880910683012, 'mean_word_length': 3.3173803526448364, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '159930', 'n_tokens_mistral': 742, 'n_tokens_neox': 672, 'n_words': 155}