Skip to content

Instantly share code, notes, and snippets.

View cyrusbehr's full-sized avatar

Cyrus Behroozi cyrusbehr

View GitHub Profile
@cyrusbehr
cyrusbehr / CMakeLists.txt
Last active November 27, 2019 00:10
CMakeLists AArch64
cmake_minimum_required(VERSION 3.0)
SET ( CMAKE_SYSTEM_NAME Linux )
SET ( CMAKE_SYSTEM_PROCESSOR aarch64 )
SET ( CMAKE_C_COMPILER "aarch64-linux-gnu-gcc" )
SET ( CMAKE_CXX_COMPILER "aarch64-linux-gnu-g++" )
SET ( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
SET ( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
SET ( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
@cyrusbehr
cyrusbehr / create_collection.py
Last active June 16, 2020 23:31
Create and populate a collection using C++ SDK
import tfsdk
import os
# Set the configuration options
options = tfsdk.ConfigurationOptions()
# Use the FULL model
options.fr_model = tfsdk.FACIALRECOGNITIONMODEL.FULL
# Enable vector compression
options.fr_vector_compression = True
@cyrusbehr
cyrusbehr / identify.py
Last active June 19, 2020 18:37
Run 1 to N identification using the C++ SDK
import tfsdk
import cv2
import os
# Set the configuration options
options = tfsdk.ConfigurationOptions()
# Use the FULL model
options.fr_model = tfsdk.FACIALRECOGNITIONMODEL.FULL
# Enable vector compression
@cyrusbehr
cyrusbehr / build_ncnn.sh
Created October 9, 2020 20:54
Shell script for pulling ncnn source and compiling for several platforms
# Obtain release tag 20200916, set up build directories
test -e 20200916.zip || wget https://github.com/Tencent/ncnn/archive/20200916.zip
test -e ncnn-20200916 || unzip 20200916.zip
cd ncnn-20200916
test -e build_amd64 && rm -rf build_amd64
test -e build_arm32 && rm -rf build_arm32
test -e build_arm64 && rm -rf build_arm64
mkdir build_amd64
@cyrusbehr
cyrusbehr / my_sdk.h
Created October 9, 2020 21:11
Our library API
#pragma once
#include <array>
#include <vector>
#include <memory>
namespace sdk {
enum class ErrorCode {
NO_ERROR,
FAILED
@cyrusbehr
cyrusbehr / xxd.sh
Last active April 13, 2021 22:22
Showcasing the XDD command
# xxd --> bash utility for generating hex dumps
xxd -i face_detector.param > face_detector_param.h
xxd -i face_detector.bin > face_detector_bin.h
@cyrusbehr
cyrusbehr / toolchain-aarch64.cmake
Created October 9, 2020 22:45
AArch64 toolchain file
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
SET(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
SET(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
@cyrusbehr
cyrusbehr / CMakeLists.txt
Created October 9, 2020 22:48
Root Cmake
# Build options for cross compiling
option(BUILD_ARM32 "Cross compile the SDK for arm32" OFF)
option(BUILD_ARM64 "Cross compile the SDK for arm64" OFF)
# Choose the appropriate toolchain file
if (BUILD_ARM32)
SET (CMAKE_TOOLCHAIN_FILE tools/toolchain-arm32.cmake)
elseif(BUILD_ARM64)
SET (CMAKE_TOOLCHAIN_FILE tools/toolchain-aarch64.cmake)
endif()
@cyrusbehr
cyrusbehr / CMakeLists.txt
Created October 9, 2020 22:58
CMake MRI script
add_custom_target(my_sdk
COMMAND
/bin/echo -e 'create libmy_sdk.a\\naddlib libmy_sdk_static.a\\naddlib ${LIBCNN}\\naddlib ${LIBOPENCV_CORE}\\naddlib ${LIBOPENCV_IMGCODECS}\\naddlib ${LIBOPENCV_IMGPROC}\\naddlib ${LIBOPENCV_ZLIB}\\naddlib ${LIBOPENCV_PNG}\\naddlib ${LIBOPENCV_TIFF}\\naddlib ${LIBOPENCV_JPG}\\nsave\\nend' | ar -M
DEPENDS
my_sdk_static
COMMENT
"Merging dependency libraries into my_sdk_static to create libmy_sdk.a"
)
@cyrusbehr
cyrusbehr / test.cpp
Created October 9, 2020 23:14
Unit testing using Catch2
#define CATCH_CONFIG_MAIN
#include <iostream>
#include "my_sdk.h"
#include "catch.hpp"
TEST_CASE("Core functionality", "[core]")
{
sdk::MySDK mySdk;