Java Code Examples for org.bytedeco.javacpp.FloatPointer#put()

The following examples show how to use org.bytedeco.javacpp.FloatPointer#put() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Nd4jMatrix.java    From jstarcraft-ai with Apache License 2.0 5 votes vote down vote up
@Override
public void afterLoad() {
    matrix = Nd4j.zeros(rowSize, columnSize, order);
    manager.ensureLocation(matrix, Location.HOST);
    manager.tagLocation(matrix, Location.HOST);
    FloatPointer pointer = (FloatPointer) matrix.data().pointer();
    pointer.put(data, 0, data.length);
    data = null;
}
 
Example 2
Source File: Nd4jVector.java    From jstarcraft-ai with Apache License 2.0 5 votes vote down vote up
@Override
public void afterLoad() {
    vector = Nd4j.zeros(size, order);
    manager.ensureLocation(vector, Location.HOST);
    manager.tagLocation(vector, Location.HOST);
    FloatPointer pointer = (FloatPointer) vector.data().pointer();
    pointer.put(data, 0, data.length);
    data = null;
}
 
Example 3
Source File: GridWorldDQN.java    From burlap_caffe with Apache License 2.0 5 votes vote down vote up
@Override
public void vectorizeState(State state, FloatPointer input) {
    GridWorldState gwState = (GridWorldState) state;

    int width = gwdg.getWidth();

    input.fill(0);

    ObjectInstance agent = gwState.object(GridWorldDomain.CLASS_AGENT);
    int x = (Integer)agent.get(GridWorldDomain.VAR_X);
    int y = (Integer)agent.get(GridWorldDomain.VAR_Y);

    input.put((long)(y*width + x), 1);
}
 
Example 4
Source File: KMeans_ClusteringJ.java    From IJ-OpenCV with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void run() {
    int stacksize = imp.getStack().getSize();

    if (imp.getStack().getSize() == 1) {
        IJ.error("You need a stack of images");
        return;
    }

    // Converters
    ImagePlusMatVectorConverter isc = new ImagePlusMatVectorConverter();

    opencv_core.MatVector mvec = isc.convert(imp, MatVector.class);

    if (!showDialog()) {
        return;
    }

    // feature data
    FloatPointer featuresData = new FloatPointer((int) mvec.size() * 512);

    // Compute the histograms
    Mat mask = new Mat();
    IntPointer intPtrChannels = new IntPointer(0, 1, 2);
    IntPointer intPtrHistSize = new IntPointer(8, 8, 8);
    FloatPointer fltPtrRanges = new FloatPointer(0.0f, 255.0f, 0.0f, 255.0f, 0.0f, 255.0f);
    PointerPointer ptptranges = new PointerPointer(fltPtrRanges, fltPtrRanges, fltPtrRanges);

    Mat hist1 = new Mat();
    int n = 0;
    for (int i = 0; i < mvec.size(); i++) {
        calcHist(mvec.get(i), 1, intPtrChannels, mask, hist1, 3, intPtrHistSize, ptptranges, true, false);
        opencv_core.normalize(hist1, hist1);
        for (int j = 0; j < 512; j++) {
            featuresData.put(n, hist1.getFloatBuffer().get(j));
            n++;
        }

    }

    Mat data = new Mat((int) mvec.size(), 512, CV_32F, featuresData);

    Mat labels = new Mat();
    Mat centers = new Mat();

    opencv_core.TermCriteria tc = new opencv_core.TermCriteria(opencv_core.TermCriteria.EPS + opencv_core.TermCriteria.COUNT, 10, 1.0);

    kmeans(data, nclusters, labels, tc, 1, KMEANS_PP_CENTERS);

    String headings = "Image\t Cluster";
    ArrayList list = new ArrayList();

    String row = "";

    for (int i = 0; i < labels.rows(); i++) {
        row = imp.getStack().getSliceLabel(i + 1) + "\t" + labels.getIntBuffer().get(i);
        list.add(row);

    }

    TextWindow textWindow = new TextWindow("Clustering Table", headings, list, 600, 400);
    textWindow.setVisible(true);

}