Examples of FloatBuffer


Examples of java.nio.FloatBuffer

                    for (int i = 0; i < length; i++) {
                        ib.put((int)vv[i+offset]);
                    }
                    break;
                case CV_32F:
                    FloatBuffer fb = getFloatBuffer();
                    fb.position(index);
                    for (int i = 0; i < length; i++) {
                        fb.put((float)vv[i+offset]);
                    }
                    break;
                case CV_64F:
                    DoubleBuffer db = getDoubleBuffer();
                    db.position(index);
View Full Code Here

Examples of java.nio.FloatBuffer

        //Constants
        float blancCasse[] = {(float) 213 / 255, (float) 208 / 255, (float) 188 / 255, 1.0f};
        float noirCasse[] = {(float) 39 / 255, (float) 25 / 255, (float) 99 / 255, 1.0f};
        float noir[] = {(float) 0 / 255, (float) 0 / 255, (float) 0 / 255, 0.0f};
        float[] shine_low = {10.0f, 0.0f, 0.0f, 0.0f};
        FloatBuffer ambient_metal = FloatBuffer.wrap(noir);
        FloatBuffer diffuse_metal = FloatBuffer.wrap(noirCasse);
        FloatBuffer specular_metal = FloatBuffer.wrap(blancCasse);
        FloatBuffer shininess_metal = FloatBuffer.wrap(shine_low);

        //End

        //Quadric for all the glu models
        GLUquadric quadric = glu.gluNewQuadric();
View Full Code Here

Examples of java.nio.FloatBuffer

                if (monitorImages[p] == null) {
                    monitorImages[p] = IplImage.create(roiMask.width(), roiMask.height(), IPL_DEPTH_8U, channels);
                }

                FloatBuffer in  = transformed.getFloatBuffer();
                ByteBuffer mask = roiMask.getByteBuffer();
                ByteBuffer out  = monitorImages[p].getByteBuffer();
                while (in.hasRemaining() && out.hasRemaining() && mask.hasRemaining()) {
                    byte m = mask.get();
                    for (int z = 0; z < channels; z++) {
                        float f = in.get();
                        out.put((byte)(m == 0 ? 0 : Math.round(f*255)));
                    }
                }
                monitorWindows[1].showImage(monitorImages[p], trackingSettings.getMonitorWindowsScale()*(1<<p));

                cvSetZero(monitorImages[p]);
                cvSetImageROI(monitorImages[p], cvGetImageROI(target));
                cvConvertScale(target, monitorImages[p], 255, 0);
                cvResetImageROI(monitorImages[p]);
                infoLogString += realityAugmentor.drawRoi(monitorImages[p], p, undistortedCameraImage, transformer, parameters);
                monitorWindows[2].showImage(monitorImages[p], trackingSettings.getMonitorWindowsScale()*(1<<p));
                if (frameRecorder != null) {
                    cvResize(monitorImages[p], undistortedCameraImage, CV_INTER_LINEAR);
                    undistortedCameraImage.applyGamma(1/2.2);
                    frameRecorder.record(undistortedCameraImage);
                }

//                double[] outlierThresholds = alignerSettings.getOutlierThresholds();
//                double outlierThreshold2 = aligner.getRMSE()*outlierThresholds[Math.min(outlierThresholds.length-1, p)];
//                outlierThreshold2 *= outlierThreshold2;

                in = residual.getFloatBuffer();
                mask.position(0);
                out.position(0);
                while (in.hasRemaining() && out.hasRemaining() && mask.hasRemaining()) {
                    byte m = mask.get();
//                        double magnitude2 = 0;
                    for (int z = 0; z < channels; z++) {
                        float f = Math.abs(in.get());
//                            magnitude2 += f*f;
                        out.put((byte)(m == 0 ? 0 : Math.round(f*255)));
                    }
//                        byte value = (byte)(m == 0 || magnitude2 < outlierThreshold2 ? 0 : 255);
//                        for (int z = 0; z < channels; z++) {
View Full Code Here

Examples of java.nio.FloatBuffer

                for (int i = 0; i < sb.capacity(); i++) {
                    db.put(i, (short)Math.max(Math.min(sb.get(i) & 0xFFFF,max),min));
                }
                break; }
            case IPL_DEPTH_32F: {
                FloatBuffer sb = src.getByteBuffer().asFloatBuffer();
                FloatBuffer db = dst.getByteBuffer().asFloatBuffer();
                for (int i = 0; i < sb.capacity(); i++) {
                    db.put(i, (float)Math.max(Math.min(sb.get(i),max),min));
                }
                break; }
            case IPL_DEPTH_8S: {
                ByteBuffer sb = src.getByteBuffer();
                ByteBuffer db = dst.getByteBuffer();
                for (int i = 0; i < sb.capacity(); i++) {
                    db.put(i, (byte)Math.max(Math.min(sb.get(i),max),min));
                }
                break; }
            case IPL_DEPTH_16S: {
                ShortBuffer sb = src.getByteBuffer().asShortBuffer();
                ShortBuffer db = dst.getByteBuffer().asShortBuffer();
                for (int i = 0; i < sb.capacity(); i++) {
                    db.put(i, (short)Math.max(Math.min(sb.get(i),max),min));
                }
                break; }
            case IPL_DEPTH_32S: {
                IntBuffer sb = src.getByteBuffer().asIntBuffer();
                IntBuffer db = dst.getByteBuffer().asIntBuffer();
                for (int i = 0; i < sb.capacity(); i++) {
                    db.put(i, (int)Math.max(Math.min(sb.get(i),max),min));
                }
                break; }
            case IPL_DEPTH_64F: {
                DoubleBuffer sb = src.getByteBuffer().asDoubleBuffer();
                DoubleBuffer db = dst.getByteBuffer().asDoubleBuffer();
                for (int i = 0; i < sb.capacity(); i++) {
                    db.put(i, Math.max(Math.min(sb.get(i),max),min));
                }
                break; }
            default: assert(false);
        }
View Full Code Here

Examples of java.nio.FloatBuffer

        if (image.roi() != null) {
            height = image.roi().height();
            width  = image.roi().width();
            start  = image.roi().yOffset()*step/4 + image.roi().xOffset()*channels;
        }
        FloatBuffer fb = image.getFloatBuffer(start);
        double[] h = H == null ? null : H.get();
        for (int y = 0; y < height; y++) {
            for (int x = 0; x < width; x++) {
                for (int z = 0; z < channels; z++) {
                    double sum = 0.0;
                    if (h == null) {
                        sum += line[x];
                    } else {
                        double x2 = (h[0]*x + h[1]*y + h[2])/(h[6]*x + h[7]*y + h[8]);
                        while (x2 < 0) {
                            x2 += line.length;
                        }
                        int xi2   = (int)x2;
                        double xn = x2 - xi2;
                        sum += line[ xi2   %line.length]*(1-xn) +
                               line[(xi2+1)%line.length]*xn;
                    }
                    minMax[0] = Math.min(minMax[0], sum);
                    minMax[1] = Math.max(minMax[1], sum);
                    fb.put(y*step/4 + x*channels + z, (float)sum);
                }
            }
        }

        cvConvertScale(image, image, 1/(minMax[1]-minMax[0]),
View Full Code Here

Examples of java.nio.FloatBuffer

        // recover (very very smooth) ambient light by removing distortions
        // caused by the reflectance map
        // cvDiv(image1, image3, image1, 1);
        // cvDiv() doesn't support division by zero...
        FloatBuffer fb1 = float1.getFloatBuffer();
        FloatBuffer fb2 = float2.getFloatBuffer();
        ByteBuffer  rmb = roiMask.getByteBuffer();
        assert(fb1.capacity() == fb2.capacity()/3);
        assert(fb1.capacity() == rmb.capacity()/3);
        int[] nPixels = new int[channels];
        for (int i = 0, j = 0; j < fb1.capacity(); i++, j+=channels) {
            for (int z = 0; z < channels; z++) {
                float ra = fb1.get(j+z);
                float r  = fb2.get(j+z);
                float a  = ra/r;
                fb1.put(j+z, a);
                if (rmb.get(i) != 0) {
                    if (r > reflectanceMin) {
                        nPixels[z]++;
View Full Code Here

Examples of java.nio.FloatBuffer

        int channels = residual.nChannels();
        thresholdedImage = IplImage.createIfNotCompatible(thresholdedImage, roiMask);
        cvResetImageROI(thresholdedImage);

        ByteBuffer roiMaskBuf = roiMask.getByteBuffer();
        FloatBuffer residualBuf = residual.getFloatBuffer();
        FloatBuffer targetBuf = target.getFloatBuffer();
        FloatBuffer transformedBuf = transformed.getFloatBuffer();
        ByteBuffer thresholdedBuf = thresholdedImage.getByteBuffer();
        while (roiMaskBuf.hasRemaining() && residualBuf.hasRemaining() &&
                targetBuf.hasRemaining() && transformedBuf.hasRemaining() &&
                thresholdedBuf.hasRemaining()) {
            byte m = roiMaskBuf.get();
            if (m == 0) {
                residualBuf.position(residualBuf.position() + channels);
                targetBuf.position(targetBuf.position() + channels);
                transformedBuf.position(transformedBuf.position() + channels);
                thresholdedBuf.put((byte)0);
            } else {
                double relativeNorm = 0;
                double lightness = 0;
                for (int z = 0; z < channels; z++) {
                    float r = Math.abs(residualBuf.get());
                    float c = targetBuf.get();
                    float t = transformedBuf.get();
                    lightness += Math.max(c,t);
                    relativeNorm = Math.max(r/Math.max(c,t), relativeNorm);
                }
                if (lightness < channels*settings.lightnessMin) {
                    thresholdedBuf.put((byte)0);
View Full Code Here

Examples of java.nio.FloatBuffer

        int neighbor = -1;
        double d, dist1 = 1e6, dist2 = 1e6;

        for (int i = 0; i < modelDescriptors.length; i++) {
            CvSURFPoint kp = modelKeypoints[i];
            FloatBuffer mvec = modelDescriptors[i];
            if (laplacian != kp.laplacian())
                continue;
            d = compareSURFDescriptors(vec, mvec, dist2);
            if (d < dist1) {
                dist2 = dist1;
View Full Code Here

Examples of java.nio.FloatBuffer

    private ArrayList<Integer> findPairs(CvSURFPoint[] objectKeypoints, FloatBuffer[] objectDescriptors,
               CvSURFPoint[] imageKeypoints, FloatBuffer[] imageDescriptors) {
        ArrayList<Integer> ptpairs = new ArrayList<Integer>(2*objectDescriptors.length);
        for (int i = 0; i < objectDescriptors.length; i++ ) {
            CvSURFPoint kp = objectKeypoints[i];
            FloatBuffer descriptor = objectDescriptors[i];
            int nearestNeighbor = naiveNearestNeighbor(descriptor, kp.laplacian(), imageKeypoints, imageDescriptors);
            if (nearestNeighbor >= 0) {
                ptpairs.add(i);
                ptpairs.add(nearestNeighbor);
            }
View Full Code Here

Examples of java.nio.FloatBuffer

          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        } else if (type.getName().equals(CAS.TYPE_NAME_FLOAT_ARRAY)) {
          arrayStart = getArrayStartAddress(fs.getAddress());
          buf = ByteBuffer.allocate(arraySize * 4);
          FloatBuffer floatbuf = buf.asFloatBuffer();
          float[] floatArray = new float[arraySize];
          for (int i = arrayStart; i < arrayStart + arraySize; i++) {
            floatArray[i - arrayStart] = Float.intBitsToFloat(this.getHeap().heap[i]);
          }
          floatbuf.put(floatArray);
          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        } else if (type.getName().equals(CAS.TYPE_NAME_BOOLEAN_ARRAY)
            || type.getName().equals(CAS.TYPE_NAME_BYTE_ARRAY)) {
          arrayStart = this.getHeap().heap[getArrayStartAddress(fs.getAddress())];
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.