Compare commits
No commits in common. 'd477d24d39c538bef36762d22ed2bd1978071370' and '1b875f6d70461afe0526ee90ba19211bd856b254' have entirely different histories.
d477d24d39
...
1b875f6d70
@ -1,97 +1,73 @@
|
||||
BASE_DIR=../../../
|
||||
|
||||
AWSM_CC=awsm
|
||||
|
||||
NATIVE_CC=clang
|
||||
NATIVE_CFLAGS = -I. -DCPU_FREQ=3600 -O3 -lm -DSOD_DISABLE_CNN -DLIBCOX_DISABLE_DISK_IO
|
||||
|
||||
OPTFLAGS=-O3 -flto
|
||||
|
||||
WASM_CC=wasm32-unknown-unknown-wasm-clang
|
||||
WASM_LDFLAGS=-Wl,-z,stack-size=524288,--allow-undefined,--no-threads,--stack-first,--no-entry,--export-all,--export=main,--export=dummy
|
||||
WASM_CFLAGS=${WASM_LDFLAGS} -nostartfiles -DWASM -I. -DSOD_DISABLE_CNN -lm -DLIBCOX_DISABLE_DISK_IO
|
||||
|
||||
MEMC_64=64bit_nix.c
|
||||
|
||||
# for aWsm compiler
|
||||
# Currently only uses wasmception backing
|
||||
AWSM_DIR=${BASE_DIR}/awsm/
|
||||
AWSM_RT_DIR=${AWSM_DIR}/runtime/
|
||||
AWSM_RT_MEM=${AWSM_RT_DIR}/memory/
|
||||
AWSM_RT_LIBC=${AWSM_RT_DIR}/libc/wasmception_backing.c
|
||||
AWSM_RT_ENV=${AWSM_RT_DIR}/libc/env.c
|
||||
AWSM_RT_RT=${AWSM_RT_DIR}/runtime.c
|
||||
AWSM_RT_MEMC=${AWSM_RT_MEM}/${MEMC_64}
|
||||
DUMMY=${AWSM_DIR}/code_benches/dummy.c
|
||||
|
||||
# for SLEdge serverless runtime
|
||||
SLEDGE_RT_DIR=${BASE_DIR}/runtime/
|
||||
SLEDGE_RT_INC=${SLEDGE_RT_DIR}/include/
|
||||
SLEDGE_MEMC=${SLEDGE_RT_DIR}/compiletime/memory/${MEMC_64}
|
||||
|
||||
SLEDGE_BIN_DIR=${SLEDGE_RT_DIR}/bin/
|
||||
WASMISA=${SLEDGE_RT_DIR}/compiletime/instr.c
|
||||
|
||||
SAMPLES = resize_image \
|
||||
license_plate_detection
|
||||
|
||||
#SAMPLES = batch_img_loading \
|
||||
# blob_detection \
|
||||
# canny_edge_detection \
|
||||
# cnn_coco \
|
||||
# cnn_face_detection \
|
||||
# cnn_object_detection \
|
||||
# cnn_voc \
|
||||
# crop_image \
|
||||
# dilate_image \
|
||||
# erode_image \
|
||||
# grayscale_image \
|
||||
# hilditch_thin \
|
||||
# hough_lines_detection \
|
||||
# license_plate_detection \
|
||||
# minutiae \
|
||||
# otsu_image \
|
||||
# realnet_face_detection \
|
||||
# realnet_face_detection_embedded \
|
||||
# realnet_train_model \
|
||||
# resize_image \
|
||||
# rnn_text_gen \
|
||||
# rotate_image \
|
||||
# sobel_operator_img
|
||||
|
||||
all: dir copy
|
||||
|
||||
dir:
|
||||
@mkdir -p bin/
|
||||
|
||||
copy:
|
||||
cp samples/*.png bin/
|
||||
cp samples/*.jpg bin/
|
||||
|
||||
.PHONY: samples.wasm
|
||||
samples.wasm: resize_image.wasm license_plate_detection.wasm
|
||||
|
||||
.PHONY: samples.so
|
||||
samples.so: resize_image.so license_plate_detection.so
|
||||
|
||||
.PHONY: samples.out
|
||||
samples.out: resize_image.out license_plate_detection.out
|
||||
|
||||
%.wasm: samples/%.c
|
||||
@$(WASM_CC) $(WASM_CFLAGS) $(OPTFLAGS) sod.c $< $(DUMMY) -o bin/$@
|
||||
|
||||
%.out: %.wasm
|
||||
@$(AWSM_CC) $< -o $(<:.wasm=.bc)
|
||||
@$(NATIVE_CC) ${CFLAGS} ${EXTRA_CFLAGS} $(OPTFLAGS) -DUSE_MEM_VM bin/$(<:.wasm=.bc) $(AWSM_RT_LIBC) $(AWSM_RT_RT) $(AWSM_RT_ENV) $(AWSM_RT_MEMC) -o $@
|
||||
|
||||
%.so: %.wasm
|
||||
@$(AWSM_CC) --inline-constant-globals --runtime-globals bin/$< -o bin/$(@:.so=.bc)
|
||||
@$(NATIVE_CC) --shared -fPIC ${CFLAGS} ${EXTRA_CFLAGS} $(OPTFLAGS) -DUSE_MEM_VM -I${SLEDGE_RT_INC} bin/$(@:.so=.bc) $(WASMISA) ${SLEDGE_MEMC} -o bin/$@
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f bin/*
|
||||
rm -f *.wasm
|
||||
rm -f *.bc
|
||||
rm -f *.so
|
||||
rm -f *.out
|
||||
BASE_DIR=../
|
||||
include Makefile.wasm.inc
|
||||
|
||||
# SOD does not generally require a Makefile to build. Just drop sod.c and its accompanying
|
||||
# header files on your source tree and you are done.
|
||||
NCC = clang
|
||||
NCFLAGS = -I. -DCPU_FREQ=3600 -O3 -lm -DSOD_DISABLE_CNN -DLIBCOX_DISABLE_DISK_IO
|
||||
WCFLAGS = -DWASM -I. -DSOD_DISABLE_CNN -lm -DLIBCOX_DISABLE_DISK_IO
|
||||
|
||||
#sod: sod.c
|
||||
# $(CC) sod.c samples/cnn_face_detection.c -o sod_face_detect -I. $(CFLAGS)
|
||||
|
||||
EXT = out
|
||||
WEXT = wout
|
||||
|
||||
SAMPLES = resize_image \
|
||||
license_plate_detection
|
||||
|
||||
#SAMPLES = batch_img_loading \
|
||||
# blob_detection \
|
||||
# canny_edge_detection \
|
||||
# cnn_coco \
|
||||
# cnn_face_detection \
|
||||
# cnn_object_detection \
|
||||
# cnn_voc \
|
||||
# crop_image \
|
||||
# dilate_image \
|
||||
# erode_image \
|
||||
# grayscale_image \
|
||||
# hilditch_thin \
|
||||
# hough_lines_detection \
|
||||
# license_plate_detection \
|
||||
# minutiae \
|
||||
# otsu_image \
|
||||
# realnet_face_detection \
|
||||
# realnet_face_detection_embedded \
|
||||
# realnet_train_model \
|
||||
# resize_image \
|
||||
# rnn_text_gen \
|
||||
# rotate_image \
|
||||
# sobel_operator_img
|
||||
|
||||
SAMPLESOUT = $(SAMPLES:%=%.$(EXT))
|
||||
SAMPLESWOUT = $(SAMPLES:%=%.$(WEXT))
|
||||
|
||||
all: clean dir copy
|
||||
|
||||
native: samples
|
||||
wasm: samples.wasm
|
||||
# samples.wasm
|
||||
# samples
|
||||
|
||||
dir:
|
||||
mkdir -p bin/
|
||||
|
||||
copy:
|
||||
cp samples/*.png bin/
|
||||
cp samples/*.jpg bin/
|
||||
|
||||
samples: $(SAMPLESOUT)
|
||||
|
||||
samples.wasm: $(SAMPLESWOUT)
|
||||
|
||||
%.$(EXT):
|
||||
$(NCC) $(NCFLAGS) sod.c samples/$(@:%.$(EXT)=%.c) -o bin/$@
|
||||
|
||||
%.$(WEXT):
|
||||
$(WASMCC) $(WCFLAGS) $(WASMCFLAGS) $(OPTFLAGS) sod.c samples/$(@:%.$(WEXT)=%.c) $(DUMMY) -o bin/$(@:%.$(WEXT)=%.wasm)
|
||||
$(SFCC) bin/$(@:%.$(WEXT)=%.wasm) -o bin/$(@:%.$(WEXT)=%.bc)
|
||||
$(CC) ${CFLAGS} ${EXTRA_CFLAGS} $(OPTFLAGS) -D$(USE_MEM) bin/$(@:%.$(WEXT)=%.bc) $(RT_LIBC) $(RT_RT) ${MEMC} -o bin/$@
|
||||
|
||||
clean:
|
||||
rm -f bin/*
|
||||
|
@ -0,0 +1,38 @@
|
||||
BASE=awsm
|
||||
SFCC=silverfish
|
||||
CC=clang
|
||||
WASMCC=wasm32-unknown-unknown-wasm-clang
|
||||
|
||||
OPTFLAGS=-O3 -flto
|
||||
# same stack-size for all
|
||||
WASMLINKFLAGS=-Wl,-z,stack-size=524288,--allow-undefined,--no-threads,--stack-first,--no-entry,--export-all,--export=main,--export=dummy
|
||||
WASMCFLAGS=${WASMLINKFLAGS} -nostartfiles
|
||||
|
||||
MEMC_64=64bit_nix.c
|
||||
MEMC_NO=no_protection.c
|
||||
MEMC_GEN=generic.c
|
||||
MEMC_MPX=mpx.c
|
||||
MEMC_SEG=segmented.c
|
||||
|
||||
# for silverfish
|
||||
RT_DIR=${BASE_DIR}/runtime/
|
||||
RT_MEM=${RT_DIR}/memory/
|
||||
RT_LIBC=${RT_DIR}/libc/libc_backing.c
|
||||
RT_RT=${RT_DIR}/runtime.c
|
||||
|
||||
MEMC=${RT_MEM}/${MEMC_64}
|
||||
DUMMY=${BASE_DIR}/code_benches/dummy.c
|
||||
|
||||
# for awsm
|
||||
ABASE_DIR=${BASE_DIR}/../
|
||||
ART_DIR=${ABASE_DIR}/runtime/
|
||||
ART_INC=${ART_DIR}/include/
|
||||
|
||||
USE_MEM=USE_MEM_VM
|
||||
ifeq ($(USE_MEM),USE_MEM_VM)
|
||||
AMEMC=${ART_DIR}/compiletime/memory/${MEMC_64}
|
||||
endif
|
||||
WASMISA=${ART_DIR}/compiletime/instr.c
|
||||
|
||||
ABIN_DIR=${ART_DIR}/bin/
|
||||
TMP_DIR=tmp/
|
@ -1,47 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "sod.h"
|
||||
|
||||
#define MAX_IMG_SZ 1024*1024
|
||||
|
||||
int main()
|
||||
{
|
||||
unsigned char *zInpbuf = NULL;
|
||||
|
||||
zInpbuf = malloc(MAX_IMG_SZ);
|
||||
if (!zInpbuf)
|
||||
{
|
||||
perror("malloc");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ssize_t imgSz = read(0, zInpbuf, MAX_IMG_SZ);
|
||||
if (imgSz <= 0)
|
||||
{
|
||||
perror("read");
|
||||
free(zInpbuf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
sod_img imgIn = sod_img_load_from_mem(zInpbuf, imgSz, SOD_IMG_COLOR /* full color channels */);
|
||||
if (imgIn.data == 0) {
|
||||
/* Invalid path, unsupported format, memory failure, etc. */
|
||||
//puts("Cannot load input image..exiting");
|
||||
printf("Error loading input\n");
|
||||
free(zInpbuf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < imgIn.w * imgIn.h * imgIn.c; i++)
|
||||
{
|
||||
imgIn.data[i] = 255.0f - imgIn.data[i];
|
||||
}
|
||||
sod_img_save_as_png(imgIn, NULL);
|
||||
sod_free_image(imgIn);
|
||||
free(zInpbuf);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in new issue