<commit_before>"""
frame_grabber.py

>>> python frame_grabber.py [from dir] [to dir] [frame capture rate]

"""
import hpidol as hp
import cv2, sys, shutil
import numpy as np
import scipy.misc, os



def post_img(image):
	return hp.recognize_logos(image)

def do_videos(from_dir, to_dir, save_time = 1):
	for video_name in os.listdir(from_dir):
		csv_file = to_dir + "/" + video_name[:-4] + ".csv"
		if not os.path.isfile(csv_file):
			f = open(text_file, 'w')
			f.write("video_time,job_id\n")

			video_file = from_dir + "/" + video_name
			cap = cv2.VideoCapture(video_file)

			seconds_from_start = 0
			
			while cap.isOpened():
				ret, frame = cap.read()
				if not ret:
					break
				
				video_time = cap.get(cv2.cv.CV_CAP_PROP_POS_MSEC)
				
				if ((video_time/1000) - seconds_from_start) > 1:
					
					frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
					job_id = post_img(frame, api_key)
					f.write(str(video_time/1000) + "," + str(job_id) + "\n")
					seconds_from_start += save_time

			f.close()

def get_logos(from_dir, to_dir):
	for csv in from_dir:
		csv_file = from_dir + "/" + csv
		csv_logo_file = to_dir + "/" csv[:-4] + "_logos.csv"
		if not os.path.isfile(csv_logo_file):
			<commit_msg>incomplete stuff<commit_after>"""
frame_grabber.py

>>> python frame_grabber.py [from dir] [to dir] [frame capture rate]

"""
import hpidol as hp
import cv2, sys, shutil
import numpy as np
import scipy.misc, os
import pandas as pd
from collections import Counter



def post_img(image):
	return hp.recognize_logos(image)

def get_logos(job_id):
	return hp.get_logos_result(job_id)

def do_videos(from_dir, to_dir, save_time = 1):
	for video_name in os.listdir(from_dir):
		csv_file = to_dir + "/" + video_name[:-4] + ".csv"
		if not os.path.isfile(csv_file):
			f = open(csv_file, 'w')
			f.write("video_time,job_id\n")

			video_file = from_dir + "/" + video_name
			cap = cv2.VideoCapture(video_file)

			seconds_from_start = 0
			
			while cap.isOpened():
				ret, frame = cap.read()
				if not ret:
					break
				
				video_time = cap.get(cv2.cv.CV_CAP_PROP_POS_MSEC)
				
				if ((video_time/1000) - seconds_from_start) > 1:
					
					frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
					job_id = post_img(frame, api_key)
					f.write(str(video_time/1000) + "," + str(job_id) + "\n")
					seconds_from_start += save_time

			f.close()

def get_logos(from_dir, to_file):
	
	f = open(text_file, 'w')
	for csv in from_dir:
		csv_file = from_dir + "/" + csv
		
		df = pd.read_csv(csv_file)
		
		
		for row in df:
			found_logos.append(get_logos(row[1]))

{'fraction_non_alphanumeric': 0.13302217036172695, 'fraction_numerical': 0.014780241151302996, 'mean_word_length': 3.442141623488774, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '5727044', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1026, 'n_words': 218}