Home | History | Annotate | Download | only in test
      1 package org.opencv.test.highgui;
      2 
      3 import org.opencv.core.MatOfByte;
      4 import org.opencv.core.MatOfInt;
      5 import org.opencv.imgcodecs.Imgcodecs;
      6 import org.opencv.test.OpenCVTestCase;
      7 import org.opencv.test.OpenCVTestRunner;
      8 
      9 public class HighguiTest extends OpenCVTestCase {
     10 
     11     public void testImdecode() {
     12         fail("Not yet implemented");
     13     }
     14 
     15     public void testImencodeStringMatListOfByte() {
     16         MatOfByte buff = new MatOfByte();
     17         assertEquals(0, buff.total());
     18         assertTrue( Imgcodecs.imencode(".jpg", gray127, buff) );
     19         assertFalse(0 == buff.total());
     20     }
     21 
     22     public void testImencodeStringMatListOfByteListOfInteger() {
     23         MatOfInt  params40 = new MatOfInt(Imgcodecs.IMWRITE_JPEG_QUALITY, 40);
     24         MatOfInt  params90 = new MatOfInt(Imgcodecs.IMWRITE_JPEG_QUALITY, 90);
     25         /* or
     26         MatOfInt  params = new MatOfInt();
     27         params.fromArray(Imgcodecs.IMWRITE_JPEG_QUALITY, 40);
     28         */
     29         MatOfByte buff40 = new MatOfByte();
     30         MatOfByte buff90 = new MatOfByte();
     31 
     32         assertTrue( Imgcodecs.imencode(".jpg", rgbLena, buff40, params40) );
     33         assertTrue( Imgcodecs.imencode(".jpg", rgbLena, buff90, params90) );
     34 
     35         assertTrue(buff40.total() > 0);
     36         assertTrue(buff40.total() < buff90.total());
     37     }
     38 
     39     public void testImreadString() {
     40         dst = Imgcodecs.imread(OpenCVTestRunner.LENA_PATH);
     41         assertTrue(!dst.empty());
     42         assertEquals(3, dst.channels());
     43         assertTrue(512 == dst.cols());
     44         assertTrue(512 == dst.rows());
     45     }
     46 
     47     public void testImreadStringInt() {
     48         dst = Imgcodecs.imread(OpenCVTestRunner.LENA_PATH, 0);
     49         assertTrue(!dst.empty());
     50         assertEquals(1, dst.channels());
     51         assertTrue(512 == dst.cols());
     52         assertTrue(512 == dst.rows());
     53     }
     54 
     55     public void testImwriteStringMat() {
     56         fail("Not yet implemented");
     57     }
     58 
     59     public void testImwriteStringMatListOfInteger() {
     60         fail("Not yet implemented");
     61     }
     62 
     63 }
     64