Skip to content

Instantly share code, notes, and snippets.

@ZhangMenghe
ZhangMenghe / readme.md
Last active April 2, 2023 14:53
Protobuf for Android and Android NDK

Using

  • Ubuntu 18.02
  • Android NDK 20.0.5594570
  • Protobuf v3.12.2
  • Language C++ / Java

Use clang:

S1: Generate standalone toolchain

@ZhangMenghe
ZhangMenghe / .gitignore
Created November 14, 2019 21:00
Android Studio .gitignore
# Built application files
/*/build/
# Crashlytics configuations
com_crashlytics_export_strings.xml
# Local configuration file (sdk path, etc)
local.properties
# Gradle generated files
@ZhangMenghe
ZhangMenghe / note.md
Last active January 14, 2020 23:11
Build MediaPipe

Install MediaPipe

  • Follow the stepsHERE
  • Can build the Brazel project for both desktop and Android:
    • ubuntu $ bazel build -c opt \ --define MEDIAPIPE_DISABLE_GPU=1 \ --define no_aws_support=true \ mediapipe/examples/desktop/object_detection:object_detection_tensorflow and then `$ GLOG_logtostderr=1 bazel-bin/mediapipe/examples/desktop/object_detection/object_detection_tensorflow
      --calculator_graph_config_file=mediapipe/graphs/object_detection/object_detection_desktop_tensorflow_graph.pbtxt \
@ZhangMenghe
ZhangMenghe / ball_tracking.py
Created August 16, 2019 15:55
ball_tracking
from collections import deque # use to draw the last position line
import numpy as np
import argparse
import imutils # helpful library (pyimagesearch.com)
import cv2
from centroidtracker import CentroidTracker
import time
# construct argument parse input
# ap = argparse.ArgumentParser()
# ap.add_argument("-v", "--video", help="path to the (optional) video file")
@ZhangMenghe
ZhangMenghe / android_restart.java
Created July 29, 2019 18:25
[Code snippet][Android] Restart Application
//M1: exit and re-enter the application
Intent mStartActivity = new Intent(this, MainActivity.class);
int mPendingIntentId = 123456;
PendingIntent mPendingIntent = PendingIntent.getActivity(this, mPendingIntentId, mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager mgr = (AlarmManager)this.getSystemService(Context.ALARM_SERVICE);
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent);
System.exit(0);
//M2: let the current activity finish, app itself won't close
Intent i = new Intent(this, MainActivity.class);
@ZhangMenghe
ZhangMenghe / unsupervised_dnp.md
Last active April 3, 2019 00:30
[NfP] Unsupervised Learning of Depth, Normal and Ego-motion from Video

Tags: Unsupervised Learning, Monocular Video, KITTI

  • Unsupervised learning framework for task of monocular depth and camera motion estimation from unstructured video sequences.

Backgrounds

Warping-based view synthesis

  • create novel views of a specific subject from images fromdifferent view points
  • explicitly reconstruct the accurate 3D model.
  • forced to learn intermediate precictions of geometry and/or correspondences.
  • View Synthesis itself is mostly a graphics problem, and able to work in an end-to-end learning-based framework. However, in this way, geometry correspondences lose.
  • Related papers:
@ZhangMenghe
ZhangMenghe / Mask R-CNN.md
Last active April 2, 2019 23:31
[NfP] Instance Segmentation

Tags: 2017 Instance Segmentation

Priors

Faster R-CNN for object detection

Implementation

Steps

  1. Scan the image and generate the proposals(areas likely to contain an object)
  2. Classify the proposals and generate bounding boxes and masks.

Backbone

ResNet50/ResNet101: feature extractor(early layers for low-level features, later for high-level features.)

@ZhangMenghe
ZhangMenghe / restore_tf_checkpoints.py
Created March 5, 2019 22:57
Restore tensorflow checkpoints and add new variables to train
#!/usr/bin/env python
import sys
import tensorflow as tf
import numpy as np
from tensorflow.examples.tutorials.mnist import input_data
class Model(object):
def __init__(self, x, with_new_layer=False):
@ZhangMenghe
ZhangMenghe / linux_cheat_sheet.md
Last active March 31, 2020 22:50
Linux Cheatsheet

Basics

  • ls dir file listing -al - with hidden files
  • rm del -r to remove directory, -f = shift+del
  • cp srcFile dstDir copy file to dstDir with same name, -r cp directory
  • mv srcFile dstFile move or rename

System

  • alias see all alias
  • change alias or export permanatly
@ZhangMenghe
ZhangMenghe / tf_bug.md
Created February 13, 2019 18:37
[Environment][TF Bug]Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2

If you have a GPU, you shouldn't care about AVX support, because most expensive ops will be dispatched on a GPU device (unless explicitly set not to). In this case, you can simply ignore this warning by

# Just disables the warning, doesn't enable AVX/FMA
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

... or by setting export TF_CPP_MIN_LOG_LEVEL=2 if you're on Unix. Tensorflow is working fine anyway, but you won't see these annoying warnings.