Java & OpenCV can't convert RGB .gif image to GRAY - java

I want to convert pictures using Java and OpenCV from RGB to GRAY
All extensions images work correctly and I take the gray image,
just if I make .GIF image (not moving) it's give me this error:
OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cv::cvtColor
the java code :
Mat scrImg = Highgui.imread(path);
Mat dstImg = new Mat(scrImg.rows(),scrImg.cols(),scrImg.type());
Imgproc.cvtColor(scrImg, dstImg, Imgproc.COLOR_RGB2GRAY);
private static BufferedImage Mat2BufferedImage(Mat matrix){
BufferedImage bimOut;
int type;
if(matrix.channels() == 1)
type = BufferedImage.TYPE_BYTE_GRAY;
else
type = BufferedImage.TYPE_3BYTE_BGR;
int dataLength = matrix.channels()*matrix.cols()*matrix.rows();
byte [] buffer = new byte[dataLength];
bimOut = new BufferedImage(matrix.cols(),matrix.rows(),type);
matrix.get(0,0,buffer);
final byte[] bimPixels = ((DataBufferByte) bimOut.getRaster().getDataBuffer()).getData();
System.arraycopy(buffer, 0, bimPixels, 0, buffer.length);
return bimOut;
}

According to the official documentation
Currently, the following file formats are supported:
Windows bitmaps - *.bmp, *.dib (always supported)
JPEG files - *.jpeg, *.jpg, *.jpe (see the Notes section)
JPEG 2000 files - *.jp2 (see the Notes section)
Portable Network Graphics - *.png (see the Notes section)
WebP - *.webp (see the Notes section)
Portable image format - *.pbm, *.pgm, *.ppm *.pxm, *.pnm (always supported)
Sun rasters - *.sr, *.ras (always supported)
TIFF files - *.tiff, *.tif (see the Notes section)
OpenEXR Image files - *.exr (see the Notes section)
Radiance HDR - *.hdr, *.pic (always supported)
Raster and Vector geospatial data supported by Gdal (see the Notes section)
Apparently support is not included Because gif is a proprietary format.
http://answers.opencv.org/question/72134/cv2imread-cannot-read-gifs/

Related

How to save video into a file using OpenCV and Java?

Using OpenCV and Java I could live stream the video from the camera with the Java JFrame application, that means accessing the camera and capturing the video from the camera works as
well.
I want to save the video into a file, below is my code:
import ...;
public final class Main {
VideoCapture videoCapture;
Size size;
Mat matrix;
VideoWriter videoWriter;
public Main() throws SocketException, UnknownHostException, IOException {
System.load( "C:\\opencv\\build\\java\\x64\\" + Core.NATIVE_LIBRARY_NAME + ".dll");
System.load( "C:\\opencv\\build\\bin\\opencv_videoio_ffmpeg453_64.dll");
videoCapture = new VideoCapture(CAMERA_ID, CV_CAP_DSHOW);
if (videoCapture.isOpened()) {
Mat m = new Mat();
videoCapture.read(m);
int fourcc = VideoWriter.fourcc('H','2','6','4');
// int fourcc = VideoWriter.fourcc('x','2','6','4'); // Have tried, did not work.
// int fource = (int) videoCapture.get(Videoio.CAP_PROP_FOURCC); // Have tried, did not work.
// int fourcc = VideoWriter.fourcc('m','j','p','g'); // Have tried, did not work.
// int fourcc = VideoWriter.fourcc('D', 'I', 'V', 'X'); // Have tried, did not work.
double fps = videoCapture.get(Videoio.CAP_PROP_FPS);
Size s = new Size((int) videoCapture.get(Videoio.CAP_PROP_FRAME_WIDTH), (int) videoCapture.get(Videoio.CAP_PROP_FRAME_HEIGHT));
videoWriter = new VideoWriter("C:\\Users\\oconnor\\Documents\\bbbbbbbbbbbbb_1000.h264", fourcc, fps, s, true);
// Have tried, did not work
// videoWriter = new VideoWriter("C:\\Users\\oconnor\\Documents\\bbbbbbbbbbbbb_1000.avi", fourcc, fps, s, true);
// videoWriter = new VideoWriter("C:\\Users\\oconnor\\Documents\\bbbbbbbbbbbbb_1000.Mjpeg", fourcc, fps, s, true);
// videoWriter = new VideoWriter("C:\\Users\\oconnor\\Documents\\bbbbbbbbbbbbb_1000.mjpeg", fourcc, fps, s, true);
while (videoCapture.read(m)) {
videoWriter.write(m);
// Have tried, did not work.
// int i = 0;
// Mat clonedMatrix = m.clone();
// Imgproc.putText(clonedMatrix, ("frame" + i), new Point(100,100), 1, 2, new Scalar(200,0,0), 3);
// videoWriter.write(clonedMatrix);
// i++;
}
}
videoCapture.release();
videoWriter.release();
}
}
When I ran the above code, there was no error at all and the file bbbbbbbbbbbbb_1000.h264 has been created as well, but the VLC Media Player and the Windows Media Player could not play the video.
I am using Windows 10. Below is the OpenCV 4.5.3 build information. I did not build the library from sources by myself.
Video I/O:
DC1394: NO
FFMPEG: YES (prebuilt binaries)
avcodec: YES (58.134.100)
avformat: YES (58.76.100)
avutil: YES (56.70.100)
swscale: YES (5.9.100)
avresample: YES (4.0.0)
GStreamer: NO
DirectShow: YES
Media Foundation: YES
DXVA: NO
How can I save the video into a file using OpenCV and Java. It can be in Mjpeg or h264 or whatever it is as long as I can have a file to play back.
According to getBuildInformation(), your OpenCV was built with FFMPEG, so that's good.
The issue is the file extension you tried to use.
The file extension .h264 does not represent an actual container format. .h264 is the extension given to a naked H.264 stream that sits in a file without a proper container structure.
You need to give your file the extension .mp4 or some other suitable container format. MKV would be suitable. MPEG transport streams (.ts) would also be suitable.
Further, H264 may not be a valid "fourcc". avc1 is a valid fourcc.
OpenCV has builtin support for the AVI container (.avi) and an MJPEG video codec (MJPG). That will always work. More containers and codecs may be available if OpenCV was built with ffmpeg or it can use Media APIs of the operating system.
Here's some python but the API usage is the same:
import numpy as np
import cv2 as cv
# fourcc = cv.VideoWriter.fourcc(*"H264")# might not be supported
fourcc = cv.VideoWriter.fourcc(*"avc1") # that's the proper fourcc by standard
# calling with (*"avc1") is equivalent to calling with ('a', 'v', 'c', '1')
(width, height) = (640, 360)
vid = cv.VideoWriter("foo.mp4", fourcc=fourcc, fps=16, frameSize=(width, height), isColor=True)
assert vid.isOpened()
frame = np.zeros((height, width, 3), np.uint8)
for k in range(256):
frame[:,:] = (0, k, 255) # BGR order
vid.write(frame)
vid.release() # finalize the file (write headers and whatnot)
This video will be 256 frames, 16 fps, 16 seconds, and fade red to yellow.
It will also be MP4 and H.264.
Just got it work to create an AVI file. To create an AVI file, the fourcc must be as following.
int fourcc = VideoWriter.fourcc('M','J','P','G');
The file name must have .avi as the extension.
In some OS, videoCapture.get(Videoio.CAP_PROP_FPS) might return 0.0. Set a default frame per second if videoCapture.get(Videoio.CAP_PROP_FPS) returns 0.0. I've set it to 25;
Thanks #Chistoph Rackwitz and his answer in Python here, to save the video in H264, the fourcc can be as following:
int fourcc = VideoWriter.fourcc('a', 'v', 'c', '1');
And the file extension can be .ts.

How to convert image dpi (Dots per inch) in dart flutter?

The question is related to (print) DPI of various images ( for eg. of jpeg or png ) format.
This question does NOT relate to SCREEN DPI or sizes of various Android devices. It is also NOT related to showing the Bitmap on the device in screen size.
This will convert the image resolution dots per inch to 300.
Uint8List resultBytes = provider.bytes;
print(resultBytes.toString());
var dpi = 300;
resultBytes[13] = 1;
resultBytes[14] = (dpi >> 8);
resultBytes[15] = (dpi & 0xff);
resultBytes[16] = (dpi >> 8);
resultBytes[17] = (dpi & 0xff);
print(resultBytes.toString());
String tempPath = (await getTemporaryDirectory()).path;
String imgName = "IMG" + DateTime.now().microsecondsSinceEpoch.toString()+".jpg";
File file = File('$tempPath/$imgName');
await file.writeAsBytes(resultBytes);
/**You will not be able to see the image in android local storage, so rewriting the file, using the code below will show you image in Pictures Directory of android storage. Note: ImageGallerySaver is plugin, just copy and paste the dependency and have a go.*/
final result1 = ImageGallerySaver.saveFile(file.path);
print(result1);

Pink background colour in output TIFF when reading and writing some TIFF images with java ImageIO

I am attempting to merge a number of input TIFF files into a single multi-page output TIFF file using the open JDK 11 imageIO ImageReader and ImageWriter classes. My routine works correctly for almost all of my sample input files created from a number of different brands of scanning devices. These devices produce a variety of TIFF files using old and new JPEG compression. However, the TIFF files from one particular device result in an incorrect output that has a pink background. Even stranger, the TIFF produced with a portrait scan creates the correct output, while the TIFF produced with a landscape scan from the same device produces the incorrect output with a pink background. I can see no obvious difference between the 2 input files that would cause the difference in behaviour when processed by the ImageIO library.
I know that a pink background in the output usually indicates that there is a problem with transparency interpretation. I found a number of references to this issue when reading and writing JEPG images. However, I have not found any references to similar issues with TIFF images. When I walk through the ImageReader and ImageWriter in the debugger I can find no obvious difference between the input TIFF file that works and the file that produces the bad pink coloured output. Neither file has transparency. Both have the same YCbCr photometric interpretation, bands, and sub-sampling. The problematic TIFF file uses old JPEG compression, so the image write parameters explicitly specify new JPEG compression for ImageWriter. However, this is true for the similar portrait TIFF file that works correctly, so the problem must be more subtle than just the output compression.
Below is a simple command-line application that reproduces my issue.
package com.example;
import javax.imageio.IIOImage;
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.ImageWriteParam;
import javax.imageio.ImageWriter;
import javax.imageio.metadata.IIOMetadata;
import javax.imageio.metadata.IIOMetadataFormatImpl;
import javax.imageio.metadata.IIOMetadataNode;
import javax.imageio.stream.ImageInputStream;
import javax.imageio.stream.ImageOutputStream;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Iterator;
public class Main {
private static final String TIFF_FORMAT = "tiff";
private static final String IMAGEIO_PLUGIN_PACKAGE = "com.sun.imageio.plugins.tiff";
//private static final String IMAGEIO_PLUGIN_PACKAGE = "com.github.jaiimageio.impl.plugins.tiff";
public static void main(String[] args) {
if (args.length != 2) {
System.out.println("You must specify an input directory and output filename");
return;
}
File sourceDirectory = new File(args[0]);
if (!sourceDirectory.exists() || !sourceDirectory.isDirectory()) {
System.out.println(String.format("Source directory '%s' is invalid", args[0]));
}
File outputFile = new File(args[1]);
if (outputFile.exists()) {
outputFile.delete();
}
File inputFiles[] = sourceDirectory.listFiles();
mergeTiffFiles(inputFiles, outputFile);
}
/**
* Merge a list of TIFF files into a single output TIFF file using the Java ImageIO utilities.
*
* #param inputFilePaths list of input file paths to merge
* #param mergedFilePath destination path for the merged output file
*/
private static void mergeTiffFiles(
final File[] inputFilePaths,
final File mergedFilePath) {
ImageReader reader = null;
ImageWriter writer = null;
File inputFilePath = null;
try (
OutputStream outputStream = new FileOutputStream(mergedFilePath);
ImageOutputStream ios = ImageIO.createImageOutputStream(outputStream)
) {
// Initialise the output writer
writer = getTiffWriter();
writer.setOutput(ios);
writer.prepareWriteSequence(null);
// Iterate through the source files appending the pages in order within and across files
reader = getTiffReader();
for (final File filePath : inputFilePaths) {
inputFilePath = filePath;
try (
FileInputStream inputFile = new FileInputStream(filePath);
ImageInputStream inputStream = ImageIO.createImageInputStream(inputFile)
) {
reader.setInput(inputStream);
int numImages = reader.getNumImages(true);
for (int j = 0; j < numImages; j++) {
IIOMetadata imageMetadata = reader.getImageMetadata(j); // 0, first image
ImageWriteParam writeParams = getTiffWriteParams(writer, imageMetadata);
BufferedImage image = reader.read(j);
writer.writeToSequence(new IIOImage(image, null, imageMetadata), writeParams);
}
}
}
inputFilePath = null;
// Finalize the output file
writer.endWriteSequence();
} catch (Exception e) {
if (inputFilePath != null) {
throw new IllegalStateException(String.format("Error while merging TIFF file: %s", inputFilePath), e);
} else {
throw new IllegalStateException("Failed to merge TIFFs files", e);
}
} finally {
// Cleanup the reader and writer
if (writer != null) {
writer.dispose();
}
if (reader != null) {
reader.dispose();
}
}
}
/**
* Get an TIFF reader used to read the source pages - ensure we use the imageIO plugin.
*
* #return an TIFF image reader.
* #throws IOException if an reader plugin cannot be found
*/
private static ImageReader getTiffReader() throws IOException {
ImageReader reader = null;
Iterator readers = ImageIO.getImageReadersByFormatName(TIFF_FORMAT);
if (readers.hasNext()) {
do {
reader = (ImageReader) readers.next();
} while (!reader.getClass().getPackage().getName().equals(IMAGEIO_PLUGIN_PACKAGE) && readers.hasNext());
}
if (reader == null) {
throw new IOException("No imageio readers for format: " + TIFF_FORMAT);
}
return reader;
}
/**
* Get a TIFF writer used to create the merged page - ensure we use the imageIO plugin
*
* #return a TIFF image writer
* #throws IOException if an writer plugin cannot be found
*/
private static ImageWriter getTiffWriter() throws IOException {
ImageWriter writer = null;
Iterator writers = ImageIO.getImageWritersByFormatName(TIFF_FORMAT);
if (writers.hasNext()) {
do {
writer = (ImageWriter) writers.next();
} while (!writer.getClass().getPackage().getName().equals(IMAGEIO_PLUGIN_PACKAGE) && writers.hasNext());
}
if (writer == null) {
throw new IOException("No imageio writers for format: " + TIFF_FORMAT);
}
return writer;
}
/**
* Get the appropriate TIFF write parameters to apply for an input with the given image meta-data.
* Check the source image compression. If possible use the same compression settings as those from the
* input image. However, the ImageIO library doesn't support the legacy JPEG compression format for TIFF
* images. Unfortunately, there are a number of devices that create scanned TIFF images of this type
* (Xerox, HP OXP). To support the merge operation explicitly force the new JPEG compression with a high
* quality value.
*
* #param writer TIFF image writer that will use the returned image parameters
* #param imageMetadata meta-data associated with the image to write
* #return the adjusted image write parameters
*/
private static ImageWriteParam getTiffWriteParams(ImageWriter writer, IIOMetadata imageMetadata) {
// Determine the source compression type
IIOMetadataNode root =
(IIOMetadataNode) imageMetadata.getAsTree(IIOMetadataFormatImpl.standardMetadataFormatName);
IIOMetadataNode compression =
(IIOMetadataNode) root.getElementsByTagName("CompressionTypeName").item(0);
String compressionName = compression.getAttribute("value");
ImageWriteParam writeParams = writer.getDefaultWriteParam();
if (compressionName.equalsIgnoreCase("Old JPEG")) {
// Convert to modern JPEG encoding if the source uses old JPEG compression.
writeParams.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
writeParams.setCompressionType("JPEG");
double quality = 0.95;
quality = Math.max(0, Math.min(1, quality));
writeParams.setCompressionQuality((float) quality);
} else {
// Otherwise use the source image compression if possible
writeParams.setCompressionMode(ImageWriteParam.MODE_COPY_FROM_METADATA);
}
writeParams.setTilingMode(ImageWriteParam.MODE_COPY_FROM_METADATA);
return writeParams;
}
}
I expect the output of the similar landscape and portrait TIFFs to have the correct white background. I am obviously doing something wrong with the setup of the reading or writing procedure. However, there are not many options to try. The ImageReader only supports one image destination type for the TIFF files. The problem happens with the latest open JDK 11.0.4_11 version.
Okay, by inspecting the sample files, I think I have found the problem. And it's not in your code*.
When reading and writing TIFF with JPEG compression, the TIFF plugin will delegate decoding/encoding of the embedded JPEG stream to the JPEG plugin. In theory, this is simple, because the JPEG contains no color information, and the TIFF container contains the correct color information in the 262/PhotometricInterpretation tag.
In real life, this is much more complex, because sometimes the TIFF tag is missing or incorrect (especially in combination with 259/Compression tag with value 6 ("Old JPEG"). Or the JPEG encoder/decoder will make its own assumptions about color space (based on conventions for standalone JPEGs, typically JFIF or Exif), which is what I believe is the case here. The JPEG plugin bundled with the JRE uses the conventions documented here, and color space is inferred from the component ids in the SOFn marker.
For your files, we can see that the component ids differ.
Portrait file:
SOF0[ffc0, precision: 8, lines: 3520, samples/line: 2496,
components: [id: 1, sub: 1/1, sel: 0, id: 2, sub: 1/1, sel: 1, id: 3, sub: 1/1, sel: 1]]
Landscape file:
SOF0[ffc0, precision: 8, lines: 2496, samples/line: 3520,
components: [id: 0, sub: 1/1, sel: 0, id: 1, sub: 1/1, sel: 1, id: 2, sub: 1/1, sel: 1]]
The component ids in the portrait file are the normal 1, 2, and 3, while the landscape has ids 0, 1, and 2. Both files has no subsampling (ie. 1:1).
From the conventions:
If these values are 1-3 for a 3-channel image, then the image is assumed to be YCbCr [...]
Otherwise, 3-channel subsampled images are assumed to be YCbCr, 3-channel non-subsampled images are assumed to be RGB.
Because of this, the landscape image will be treated as already in RGB (and, incorrectly, not converted from YCbCr), resulting in the pinkish tint. Even though everything else in the TIFF container clearly indicates that it's YCbCr.
To fix this issue (and many other issues), I have created my own JPEG plugin that can be used as a drop-in replacement for the JRE plugin. It follows (the much simpler) conventions found in IJG's libJPEG, resulting in better color space consistency with other applications. In combination with the TIFF plugin from the same project, both your inputs are read correctly (white background). I have not tested it with the JRE TIFF plugin, but in theory, it should/could also work. Unfortunately, the TwelveMonkeys TIFF plugin does not (yet)
have the write capabilities you use (tiling) and has some limitations about what meta data it writes.
PS: As you seem to deal mainly with JPEGs that degrade in quality when re-encoding, you might want to look at merging TIFFs without decoding the image data. You can find an example of that in TIFFUtilities, written by Oliver Schmidtmer.
*) It is technically possible to work around the problem in your code, but it's kind of complex to handle all the cases correctly. If you want to implement this yourself, or are just curious I suggest you have a look at the source code for the TwelveMonkeys ImageIO JPEG plugin.

Video encode from sequence of images from java android [duplicate]

This question already has answers here:
Encode a series of Images into a Video
(4 answers)
Closed 8 years ago.
I would like to encode video from sequence of images with java only in my current android project. I mean without any use of external tools such as NDK.
Also is there any availability of java libraries for encoding video from sequence of images ?
You can use a pure java library called JCodec ( http://jcodec.org ). It contains a primitive yet working H.264 ( AVC ) encoder and a fully functioning MP4 ( ISO BMF ) muxer.
Here's a CORRECTED code sample that uses low-level API:
public void imageToMP4(BufferedImage bi) {
// A transform to convert RGB to YUV colorspace
RgbToYuv420 transform = new RgbToYuv420(0, 0);
// A JCodec native picture that would hold source image in YUV colorspace
Picture toEncode = Picture.create(bi.getWidth(), bi.getHeight(), ColorSpace.YUV420);
// Perform conversion
transform.transform(AWTUtil.fromBufferedImage(bi), yuv);
// Create MP4 muxer
MP4Muxer muxer = new MP4Muxer(sink, Brand.MP4);
// Add a video track
CompressedTrack outTrack = muxer.addTrackForCompressed(TrackType.VIDEO, 25);
// Create H.264 encoder
H264Encoder encoder = new H264Encoder(rc);
// Allocate a buffer that would hold an encoded frame
ByteBuffer _out = ByteBuffer.allocate(ine.getWidth() * ine.getHeight() * 6);
// Allocate storage for SPS/PPS, they need to be stored separately in a special place of MP4 file
List<ByteBuffer> spsList = new ArrayList<ByteBuffer>();
List<ByteBuffer> ppsList = new ArrayList<ByteBuffer>();
// Encode image into H.264 frame, the result is stored in '_out' buffer
ByteBuffer result = encoder.encodeFrame(_out, toEncode);
// Based on the frame above form correct MP4 packet
H264Utils.encodeMOVPacket(result, spsList, ppsList);
// Add packet to video track
outTrack.addFrame(new MP4Packet(result, 0, 25, 1, 0, true, null, 0, 0));
// Push saved SPS/PPS to a special storage in MP4
outTrack.addSampleEntry(H264Utils.createMOVSampleEntry(spsList, ppsList));
// Write MP4 header and finalize recording
muxer.writeHeader();
}
You can download JCodec library from a project web site or via Maven, for this add the below snippet to your pom.xml:
<dependency>
<groupId>org.jcodec</groupId>
<artifactId>jcodec</artifactId>
<version>0.1.3</version>
</dependency>
[UPDATE 1] Android users can use something like below to convert Android Bitmap object to JCodec native format:
public static Picture fromBitmap(Bitmap src) {
Picture dst = Picture.create((int)src.getWidth(), (int)src.getHeight(), RGB);
fromBitmap(src, dst);
return dst;
}
public static void fromBitmap(Bitmap src, Picture dst) {
int[] dstData = dst.getPlaneData(0);
int[] packed = new int[src.getWidth() * src.getHeight()];
src.getPixels(packed, 0, src.getWidth(), 0, 0, src.getWidth(), src.getHeight());
for (int i = 0, srcOff = 0, dstOff = 0; i < src.getHeight(); i++) {
for (int j = 0; j < src.getWidth(); j++, srcOff++, dstOff += 3) {
int rgb = packed[srcOff];
dstData[dstOff] = (rgb >> 16) & 0xff;
dstData[dstOff + 1] = (rgb >> 8) & 0xff;
dstData[dstOff + 2] = rgb & 0xff;
}
}
}

How to combine two or many tiff image files in to one multipage tiff image in JAVA

I have 5 single page tiff images.
I want to combine all these 5 tiff images in to one multipage tiff image.
I am using Java Advanced Imaging API.
I have read the JAI API documentation and tutorials given by SUN.
I am new to JAI. I know the basic core java.
I dont understand those documentation and turorial by SUN.
So friends Please tell me how to combine 5 tiff image file in to one multipage tiff image.
Please give me some guidence on above topic.
I have been searching internet for above topic but not getting any single clue.
I hope you have the computer memory to do this. TIFF image files are large.
You're correct in that you need to use the Java Advanced Imaging (JAI) API to do this.
First, you have to convert the TIFF images to a java.awt.image.BufferedImage. Here's some code that will probably work. I haven't tested this code.
BufferedImage image[] = new BufferedImage[numImages];
for (int i = 0; i < numImages; i++) {
SeekableStream ss = new FileSeekableStream(input_dir + file[i]);
ImageDecoder decoder = ImageCodec.createImageDecoder("tiff", ss, null);
PlanarImage op = new NullOpImage(decoder.decodeAsRenderedImage(0), null, null, OpImage.OP_IO_BOUND);
image[i] = op.getAsBufferedImage();
}
Then, you convert the BufferedImage array back into a multiple TIFF image. I haven't tested this code either.
TIFFEncodeParam params = new TIFFEncodeParam();
OutputStream out = new FileOutputStream(output_dir + image_name + ".tif");
ImageEncoder encoder = ImageCodec.createImageEncoder("tiff", out, params);
Vector vector = new Vector();
for (int i = 0; i < numImages; i++) {
vector.add(image[i]);
}
params.setExtraImages(vector.listIterator(1)); // this may need a check to avoid IndexOutOfBoundsException when vector is empty
encoder.encode(image[0]);
out.close();

Categories