Skip to content

Instantly share code, notes, and snippets.

View ryondev's full-sized avatar
🎯
Focusing

Ryon ryondev

🎯
Focusing
  • TikTok Inc.
  • San Jose
View GitHub Profile
@ryondev
ryondev / FaceCropUtil.java
Last active May 5, 2019 09:27
Crop Face With FaceInfo
public class FaceCropUtil {
public static Bitmap getCropedFaceFromBitmap(Bitmap bitmap, FaceInfo info) {
if (bitmap != null && info != null) {
int centerX = (int) info.mCenter_x;
int centerY = (int) info.mCenter_y;
int faceWidth = (int) (info.mWidth * 1.5f);
int faceHeight = (int) (info.mWidth * 1.6f);
Rect cropRect = new Rect(
Math.max(0, centerX - faceWidth / 2),
Math.max(0, centerY - (int) (faceHeight / 1.6f)),
@ryondev
ryondev / CommonIns.sh
Created December 13, 2018 09:49
3326 Common adb instructions
# Promission grant list
adb shell pm grant com.baidu.aip.robot android.permission.ACCESS_NETWORK_STATE
adb shell pm grant com.baidu.aip.robot android.permission.ACCESS_WIFI_STATE
adb shell pm grant com.baidu.aip.robot android.permission.BATTERY_STATS
adb shell pm grant com.baidu.aip.robot android.permission.CHANGE_WIFI_STATE
adb shell pm grant com.baidu.aip.robot android.permission.CAMERA
adb shell pm grant com.baidu.aip.robot android.permission.DISABLE_KEYGUARD
adb shell pm grant com.baidu.aip.robot android.permission.INTERNET
adb shell pm grant com.baidu.aip.robot android.permission.RECORD_AUDIO
@ryondev
ryondev / FFMPEG_Common_Ins.sh
Last active December 13, 2018 09:50
FFMPEG gists
# Push Stream
ffmpeg -f avfoundation -i "1" -vcodec libx264 -preset ultrafast -acodec libfaac -f flv rtmp://push.hainiutv.com/manatee/stream1
# PCM Play
ffplay -ar 16000 -channels 1 -f s16le -i xxx.pcm
@ryondev
ryondev / ChangePassword.java
Created March 7, 2018 14:54 — forked from zach-klippenstein/ChangePassword.java
The keystore password on Java keystore files is utterly pointless. You can reset it without knowing it, as shown by this code. Note that private keys are still secure, as far as I know. The JKS implementation is copyright Casey Marshall ([email protected]), and the original source is available at http://metastatic.org/source/JKS.java. I've in…
import java.util.*;
import java.io.*;
import java.security.*;
public class ChangePassword
{
private final static JKS j = new JKS();
public static void main(String[] args) throws Exception
{
@ryondev
ryondev / resizeImage
Created February 11, 2018 09:49
Using to resize the Image Data which from CMSampleBuffer
func resizeImage(with buffer: CMSampleBuffer) {
let pixel = CMSampleBufferGetImageBuffer(buffer)
guard let pixelBuffer = pixel else { return }
CVPixelBufferLockBaseAddress(pixelBuffer, CVPixelBufferLockFlags(rawValue: 0))
let baseAddress = CVPixelBufferGetBaseAddress(pixelBuffer)
let bytesPerRow = CVPixelBufferGetBytesPerRow(pixelBuffer)
var inputBuffer = vImage_Buffer()
inputBuffer.height = inputHeight
@ryondev
ryondev / gist:5a69824c001bae47a69a5e6fe9db3410
Created February 10, 2018 13:25 — forked from Nyx0uf/gist:217d97f81f4889f4445a
UIImage scale using vImage
-(UIImage*)mmg_imageScaledToFitSize:(CGSize)fitSize
{
// Create a vImage_Buffer from the CGImage
CGImageRef sourceRef = self.CGImage;
vImage_Buffer srcBuffer;
vImage_CGImageFormat format = {
.bitsPerComponent = 8,
.bitsPerPixel = 32,
.colorSpace = NULL,
.bitmapInfo = (CGBitmapInfo)kCGImageAlphaFirst,