2017-12-29 12:14:30 +08:00
|
|
|
package org.opencv.test.imgcodecs;
|
2011-06-30 20:07:31 +08:00
|
|
|
|
2012-04-14 05:50:59 +08:00
|
|
|
import org.opencv.core.MatOfByte;
|
2012-09-27 23:10:06 +08:00
|
|
|
import org.opencv.core.MatOfInt;
|
2014-07-10 22:27:32 +08:00
|
|
|
import org.opencv.imgcodecs.Imgcodecs;
|
2011-07-07 22:35:12 +08:00
|
|
|
import org.opencv.test.OpenCVTestCase;
|
|
|
|
import org.opencv.test.OpenCVTestRunner;
|
2011-07-04 17:30:55 +08:00
|
|
|
|
2017-12-29 12:14:30 +08:00
|
|
|
public class ImgcodecsTest extends OpenCVTestCase {
|
2011-08-05 16:39:28 +08:00
|
|
|
|
|
|
|
public void testImdecode() {
|
|
|
|
fail("Not yet implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void testImencodeStringMatListOfByte() {
|
2012-04-14 05:50:59 +08:00
|
|
|
MatOfByte buff = new MatOfByte();
|
|
|
|
assertEquals(0, buff.total());
|
2014-07-10 22:27:32 +08:00
|
|
|
assertTrue( Imgcodecs.imencode(".jpg", gray127, buff) );
|
2012-04-14 05:50:59 +08:00
|
|
|
assertFalse(0 == buff.total());
|
2011-08-05 16:39:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void testImencodeStringMatListOfByteListOfInteger() {
|
2014-07-10 22:27:32 +08:00
|
|
|
MatOfInt params40 = new MatOfInt(Imgcodecs.IMWRITE_JPEG_QUALITY, 40);
|
|
|
|
MatOfInt params90 = new MatOfInt(Imgcodecs.IMWRITE_JPEG_QUALITY, 90);
|
2012-11-09 15:46:14 +08:00
|
|
|
/* or
|
2012-09-27 23:10:06 +08:00
|
|
|
MatOfInt params = new MatOfInt();
|
2014-07-10 22:27:32 +08:00
|
|
|
params.fromArray(Imgcodecs.IMWRITE_JPEG_QUALITY, 40);
|
2012-11-09 15:46:14 +08:00
|
|
|
*/
|
2012-09-27 23:10:06 +08:00
|
|
|
MatOfByte buff40 = new MatOfByte();
|
|
|
|
MatOfByte buff90 = new MatOfByte();
|
|
|
|
|
2014-07-10 22:27:32 +08:00
|
|
|
assertTrue( Imgcodecs.imencode(".jpg", rgbLena, buff40, params40) );
|
|
|
|
assertTrue( Imgcodecs.imencode(".jpg", rgbLena, buff90, params90) );
|
2012-09-27 23:10:06 +08:00
|
|
|
|
|
|
|
assertTrue(buff40.total() > 0);
|
|
|
|
assertTrue(buff40.total() < buff90.total());
|
2011-08-05 16:39:28 +08:00
|
|
|
}
|
2011-06-30 20:07:31 +08:00
|
|
|
|
2011-08-02 21:47:40 +08:00
|
|
|
public void testImreadString() {
|
2014-07-10 22:27:32 +08:00
|
|
|
dst = Imgcodecs.imread(OpenCVTestRunner.LENA_PATH);
|
2019-05-24 16:45:09 +08:00
|
|
|
assertFalse(dst.empty());
|
2011-08-02 21:47:40 +08:00
|
|
|
assertEquals(3, dst.channels());
|
|
|
|
assertTrue(512 == dst.cols());
|
|
|
|
assertTrue(512 == dst.rows());
|
|
|
|
}
|
2011-06-30 20:07:31 +08:00
|
|
|
|
2011-08-02 21:47:40 +08:00
|
|
|
public void testImreadStringInt() {
|
2023-01-09 17:55:31 +08:00
|
|
|
dst = Imgcodecs.imread(OpenCVTestRunner.LENA_PATH, Imgcodecs.IMREAD_GRAYSCALE);
|
2019-05-24 16:45:09 +08:00
|
|
|
assertFalse(dst.empty());
|
2011-08-02 21:47:40 +08:00
|
|
|
assertEquals(1, dst.channels());
|
|
|
|
assertTrue(512 == dst.cols());
|
|
|
|
assertTrue(512 == dst.rows());
|
|
|
|
}
|
2011-07-04 17:30:55 +08:00
|
|
|
|
2011-08-05 16:39:28 +08:00
|
|
|
public void testImwriteStringMat() {
|
|
|
|
fail("Not yet implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void testImwriteStringMatListOfInteger() {
|
|
|
|
fail("Not yet implemented");
|
|
|
|
}
|
|
|
|
|
2011-06-30 20:07:31 +08:00
|
|
|
}
|