@Test /** * 1. JaveCV Face Detect image in SequenceFile from S3:// 2. JaveCV Face Detect image in * SequenceFile from hdfs:// Before hdfs over HDFS is implemented, do $hadoop fs -cp * hdfs://<path>/tmp/lena.png.seq s3://ori-tmp/lena.png.seq Eclipse: * -Djava.library.path=/home/heq/hadoop-2.2.0/lib/native * * @throws Exception */ public void testJavaCVFaceDetectionFromS3HDFS() throws Exception { String inputURI = "file://" + new File(this.getClass().getResource("/lena.png").getFile()).getAbsolutePath(); String s3URI = "s3n://ori-tmp/lena.png.seq"; Util.writeToSequenceFile(inputURI, s3URI, new SnappyCodec()); byte[] pngbytes = Util.readSequenceFileFromS3(s3URI); BufferedImage rawimage = ImageIO.read(new ByteArrayInputStream(pngbytes)); List<int[]> faces = OpenCV.detectFace(rawimage); assertTrue(faces.size() == 1); String hdfsURI = hadoopMaster + "/tmp/lena.png.seq"; Util.writeToSequenceFile(inputURI, hdfsURI, new SnappyCodec()); pngbytes = Util.readSequenceFileFromHDFS(hdfsURI); rawimage = ImageIO.read(new ByteArrayInputStream(pngbytes)); faces = OpenCV.detectFace(rawimage); assertTrue(faces.size() == 1); }
@Test /** * Test image in compressed PPM format as used in NIST Colorferet database Eclipse: * -Djava.library.path=/home/heq/hadoop-2.2.0/lib/native * * @throws Exception */ public void testFaceDetectionInPPMFromS3() throws Exception { String file = "00001_930831_hl_a.ppm"; String inputURI = "s3n://ori-colorferetsubset/00001/" + file + ".bz2"; String outputURI = hadoopMaster + "/tmp/" + file + ".seq"; Util.writeToSequenceFile(inputURI, outputURI, new SnappyCodec()); byte[] ppmbytes = Util.readSequenceFileFromHDFS(outputURI); logger.debug("file size= {}", ppmbytes.length); ImageInputStream iis = ImageIO.createImageInputStream(new ByteArrayInputStream(ppmbytes)); BufferedImage rawimage = PPMImageReader.read(iis); List<int[]> faces = OpenCV.detectFace(rawimage); assertTrue(faces.size() == 1); }