Skip to content

Instantly share code, notes, and snippets.

@saudet
saudet / AllocateStress.java
Created May 7, 2021 00:32
A simple latency check
// Same as https://gist.github.com/nebulorum/f7978aa5519cab8bece65d4dac689d4f but using LongPointer
import static java.util.concurrent.Executors.newFixedThreadPool;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import org.bytedeco.javacpp.LongPointer;
@saudet
saudet / NanoChrono.java
Last active August 28, 2020 05:13
A minimal example of a way to map std::chrono::system_clock::time_point with JavaCPP
import org.bytedeco.javacpp.*;
import org.bytedeco.javacpp.annotation.*;
/**
* java -jar /path/to/javacpp.jar NanoChrono.java
* java -cp /path/to/javacpp.jar:. NanoChrono
*/
@Platform(include = "chrono")
public class NanoChrono {
static { Loader.load(); }
@saudet
saudet / NativeBenchmark.java
Last active October 16, 2018 06:39
A few microbenchmarks for JavaCPP using JMH
/*
* Copyright (c) 2014, Oracle America, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
@saudet
saudet / RedBloodCellDetection.java
Last active March 2, 2024 17:14
Example of object detection with DL4J on images of red blood cells
package org.deeplearning4j.examples.convolution.objectdetection;
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import org.bytedeco.javacv.CanvasFrame;
import org.bytedeco.javacv.OpenCVFrameConverter;
@saudet
saudet / rostopic_list_with_moveit.txt
Last active September 21, 2017 21:39
"rostopic list" on Fetch
/arm_controller/follow_joint_trajectory/cancel
/arm_controller/follow_joint_trajectory/feedback
/arm_controller/follow_joint_trajectory/goal
/arm_controller/follow_joint_trajectory/result
/arm_controller/follow_joint_trajectory/status
/arm_with_torso_controller/follow_joint_trajectory/cancel
/arm_with_torso_controller/follow_joint_trajectory/feedback
/arm_with_torso_controller/follow_joint_trajectory/goal
/arm_with_torso_controller/follow_joint_trajectory/result
/arm_with_torso_controller/follow_joint_trajectory/status
@saudet
saudet / TSnePlot.java
Created February 17, 2017 14:19
Sample code for t-SNE visualization with T-SNE-Java or Deeplearning4j
import java.io.File;
import java.util.Arrays;
import javax.swing.JFrame;
import org.math.plot.FrameView;
import org.math.plot.Plot2DPanel;
import org.math.plot.PlotPanel;
import org.math.plot.plots.ColoredScatterPlot;
import org.math.plot.plots.ScatterPlot;
@saudet
saudet / TestGC.java
Last active June 3, 2016 02:27
Testing overhead and crashability of passing a `Pointer` vs its address to native methods
import java.util.concurrent.*;
import org.bytedeco.javacpp.*;
import org.bytedeco.javacpp.annotation.*;
@Platform(include="testgc.h")
public class TestGC {
static { Loader.load(); }
static native void processLongPtr(@Cast("float*") long ptr, long size);
static native void processPointer(FloatPointer ptr, long size);
@saudet
saudet / simple_solver.prototxt
Last active June 3, 2016 01:42
Simple Caffe model replicating the config used in MLPMnistSingleLayerExample
# The train/test net protocol buffer definition
net: "examples/mnist/simple_train_test.prototxt"
# test_iter specifies how many forward passes the test should carry out.
# In the case of MNIST, we have test batch size 100 and 100 test iterations,
# covering the full 10,000 testing images.
test_iter: 78
# Carry out testing every 500 training iterations.
test_interval: 7035
# The base learning rate, momentum and the weight decay of the network.
base_lr: 0.006
@saudet
saudet / HelloPointer.java
Last active February 27, 2016 05:44
Using JavaCPP without user-defined native libraries (bytedeco/javacpp@485081f)
// Build and execute normally:
// $ javac -cp javacpp.jar HelloPointer.java
// $ java -jar javacpp.jar HelloPointer
// $ java -cp javacpp.jar HelloPointer
import org.bytedeco.javacpp.*;
import org.bytedeco.javacpp.annotation.*;
@Platform
public class HelloPointer {