Skip to content

Instantly share code, notes, and snippets.

@novodimaporo
novodimaporo / NV21Utils.cpp
Last active June 11, 2021 09:12
NV21 Utils
void convertNV21ToArray2d(JNIEnv* env, dlib::array2d<dlib::rgb_pixel>& out,
jbyteArray data, jint width, jint height) {
jbyte* yuv = env->GetByteArrayElements(data, 0);
int frameSize = width * height;
int y, u, v, uvIndex;
int r, g, b;
out.set_size((long) height, (long) width);
for(int row = 0; row < height; row++) {
@novodimaporo
novodimaporo / convert.cpp
Created September 13, 2017 05:48
NV21 Utils, convert nv21 byte[] to dlib array2d
void convertNV21ToArray2d(JNIEnv* env, dlib::array2d<dlib::rgb_pixel>& out,
jbyteArray data, jint width, jint height) {
jbyte* yuv = env->GetByteArrayElements(data, 0);
int frameSize = width * height;
int y, u, v, uvIndex;
int r, g, b;
out.set_size((long) height, (long) width);
for(int row = 0; row < height; row++) {
@novodimaporo
novodimaporo / rx-test.kt
Last active August 30, 2017 07:21
playing with rxjava2
fun observable1() =
Observable.fromCallable {
print("new callable 1\n")
true
}
fun observable2() =
Observable.fromCallable {
print("new callable 2\n")
true
@novodimaporo
novodimaporo / OnSubscribeRenderer.kt
Created August 25, 2017 10:37
Hi I made this using patterns from other people. In this snippet, I am making an rx implementation of opengles renderer.
class OnSubscribeRenderer(private val surfaceView: GLSurfaceView,
private val previewSize: Size) : Observable<SurfaceEvent>() {
// TODO make a github gist and ask to community for insights
override fun subscribeActual(observer: Observer<in SurfaceEvent>) {
val listener = Listener(observer, previewSize)
observer.onSubscribe(listener)
surfaceView.setEGLContextClientVersion(2)
@novodimaporo
novodimaporo / OnSubscribeRenderer.kt
Created August 25, 2017 10:36
Hi I made this using patterns from other people. In this snippet, I am making an rx implementation of opengles renderer.
class OnSubscribeRenderer(private val surfaceView: GLSurfaceView,
private val previewSize: Size) : Observable<SurfaceEvent>() {
// TODO make a github gist and ask to community for insights
override fun subscribeActual(observer: Observer<in SurfaceEvent>) {
val listener = Listener(observer, previewSize)
observer.onSubscribe(listener)
surfaceView.setEGLContextClientVersion(2)
fun loadFirstPage(): ObservableTransformer<LoadFirstPageAction, MainResult> {
return ObservableTransformer {
actionStream -> actionStream.flatMap { _ -> mainModel.getNews("", "10") // <-- whats wrong with you! took 1 day of my life
.map { data -> MainResult.success(data) }
.onErrorReturn { error -> MainResult.failure(error.message ?: "Unknown error") }
.observeOn(AndroidSchedulers.mainThread())
.startWith { MainResult.loading()} }
}
}