added helper for copying and converting taken raw images to sdcard

This commit is contained in:
PythonLimited 2018-07-11 14:45:24 +02:00
parent 47e17097a1
commit 24a09f79a9
3 changed files with 103 additions and 0 deletions

15
camera/helper/Android.mk Normal file
View file

@ -0,0 +1,15 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
helper.cpp
LOCAL_SHARED_LIBRARIES := \
liblog libcutils
LOCAL_MODULE_PATH := /system/bin
LOCAL_MODULE := camera_helper
LOCAL_MODULE_TAGS := optional
LOCAL_PROPRIETARY_MODULE := true
include $(BUILD_SHARED_LIBRARY)

81
camera/helper/helper.c Normal file
View file

@ -0,0 +1,81 @@
// Copyright 2018 Leonardomeitz@gmail.com
// This is part of the NeoHomies Project
#include <stdio.h>
#include <string.h>
#include "helper.h"
static int raw_file_exists(){
int ret;
DIR *d;
struct dirent *dir;
ret = false;
d = opendir(data_path);
if (d) {
while ((dir = readdir(d)) != NULL) {
if (strstr(dir->d_name, "yuv") != NULL){
return true;
}
printf("%s\n", dir->d_name);
}
closedir(d);
}
return ret;
}
static char *get_raw_file_name(){
char *name;
DIR *d;
struct dirent *dir;
name = NULL;
d = opendir(data_path);
if (d) {
while ((dir = readdir(d)) != NULL) {
if (strstr(dir->d_name, "yuv") != NULL){
return dir->d_name;
}
printf("%s\n", dir->d_name);
}
closedir(d);
}
return name;
}
static int copy_raw_file(char *name){
// TODO
}
static int delete_raw_file(char *name){
// TODO
}
int main(){
if (raw_file_exists()) {
char *name = get_raw_file_name();
if (name != NULL) {
// TODO
if ((copy_raw_file(name) && delete_raw_file(name)) != NULL) {
return true;
}
else {
// Error while copying/deleting
return false;
}
}
else {
// This should happen, abort!
exit(EXIT_FAILURE);
}
}
else {
// Called but no file found
// Retry in 400 msec
// TODO
}
}

7
camera/helper/helper.h Normal file
View file

@ -0,0 +1,7 @@
#ifndef __helper__
#define __helper__
#define EXIT_FAILURE -1
#define data_path "/data/"
#endif