ImgcodecsTest.java 2.0 KB

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