org.bytedeco.javacpp.indexer.IntIndexer Java Examples

The following examples show how to use org.bytedeco.javacpp.indexer.IntIndexer. 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: LaneManagerTest.java    From android-robocar with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Test
public void testLaneDetection() {
  opencv_core.Mat original = LaneManager.readImage(getResourcePath(TEST_IMAGE));
  opencv_core.Mat grayscale = LaneManager.doGrayscale(original);
  opencv_core.Mat gaussian = LaneManager.doGaussianBlur(grayscale, 5);
  opencv_core.Mat edges = LaneManager.doCanny(gaussian, 50, 150);

  opencv_core.Scalar color = new opencv_core.Scalar(0, 255, 0, 0); // Green (BGR)
  opencv_core.Mat lines = LaneManager.doHoughLines(edges, 1, Math.PI / 180, 5, 20, 1);
  IntIndexer linesIndexer = lines.createIndexer();
  for (int i = 0; i < linesIndexer.rows(); i++) {
    for (int j = 0; j < linesIndexer.cols(); j++) {
      LaneManager.drawLine(original,
          new opencv_core.Point(linesIndexer.get(i, j, 0), linesIndexer.get(i, j, 1)),
          new opencv_core.Point(linesIndexer.get(i, j, 2), linesIndexer.get(i, j, 3)),
          color, 5);
    }
  }

  assertTrue(LaneManager.writeImage("/tmp/robocar_lanes.jpg", original));
}
 
Example #2
Source File: LaneManagerTest.java    From android-robocar with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testHoughLines() {
  opencv_core.Mat src = LaneManager.readImage(getResourcePath(TEST_IMAGE));
  opencv_core.Mat gray = LaneManager.doGrayscale(src);

  double rho = 1;
  double theta = Math.PI / 180;
  int threshold = 1;
  double minLineLength = 10;
  double maxLineGap = 1;
  opencv_core.Mat lines = LaneManager.doHoughLines(
      gray, rho, theta, threshold, minLineLength, maxLineGap);

  assertNotNull(lines.data());
  assertEquals(lines.rows(), TEST_IMAGE_WIDTH);
  assertEquals(lines.cols(), 1);
  assertEquals(lines.channels(), 4);

  IntIndexer linesIndexer = lines.createIndexer();
  assertEquals(linesIndexer.rows(), TEST_IMAGE_WIDTH);
  assertEquals(linesIndexer.cols(), 1);
  assertEquals(linesIndexer.channels(), 4);

  assertEquals(linesIndexer.get(0, 0, 0), 245);
  assertEquals(linesIndexer.get(0, 0, 1), 239);
  assertEquals(linesIndexer.get(0, 0, 2), 245);
  assertEquals(linesIndexer.get(0, 0, 3), 0);

  assertTrue(LaneManager.writeImage("/tmp/robocar_hough.jpg", lines));
}
 
Example #3
Source File: DefaultDataBufferFactory.java    From nd4j with Apache License 2.0 5 votes vote down vote up
/**
 * @param intPointer
 * @param length
 * @return
 */
@Override
public DataBuffer create(IntPointer intPointer, long length) {
    intPointer.capacity(length);
    intPointer.limit(length);
    intPointer.position(0);
    return new IntBuffer(intPointer, IntIndexer.create(intPointer), length);
}
 
Example #4
Source File: DefaultDataBufferFactory.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
/**
 * @param intPointer
 * @param length
 * @return
 */
@Override
public DataBuffer create(IntPointer intPointer, long length) {
    intPointer.capacity(length);
    intPointer.limit(length);
    intPointer.position(0);
    return new IntBuffer(intPointer, IntIndexer.create(intPointer), length);
}