Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Android imencode parameters

The way to set, for example, the JPEG quality with imencode with C++ is something like this:

vector<int> params;
params.push_back( cv::IMWRITE_JPEG_QUALITY );
params.push_back( 75 );
cv::imencode( ".jpg", frame, buf, params );

The question is, how to do it properly with OpenCV4Android, is this the best way?

MatOfInt params = new MatOfInt();
int[] data = {Highgui.IMWRITE_JPEG_QUALITY, 40};
params.put(0, 0, data);
Highgui.imencode(".jpg", image, buf, params);

Android imencode parameters

The way to set, for example, the JPEG quality with imencode with C++ is something like this:

vector<int> params;
params.push_back( cv::IMWRITE_JPEG_QUALITY );
params.push_back( 75 );
cv::imencode( ".jpg", frame, buf, params );

The question is, how to do it properly with OpenCV4Android, is this the best way?

//I am not sure which size of rows/cols should i initialize this Mat: 
MatOfInt params = new MatOfInt();
MatOfInt(size); 
int[] data = {Highgui.IMWRITE_JPEG_QUALITY, 40};
params.put(0, 0, data);
Highgui.imencode(".jpg", image, buf, params);

Android imencode parameters

The way to set, for example, the JPEG quality with imencode with C++ is something like this:

vector<int> params;
params.push_back( cv::IMWRITE_JPEG_QUALITY );
params.push_back( 75 );
cv::imencode( ".jpg", frame, buf, params );

The question is, how to do it properly with OpenCV4Android, is this the best way?

//I am not sure which size of rows/cols should i initialize this Mat: 
MatOfInt params = new MatOfInt(size); 
int[] data = {Highgui.IMWRITE_JPEG_QUALITY, 40};
params.put(0, 0, data);
Highgui.imencode(".jpg", image, buf, params);

And also, because imencode returns buf as a MatOfByte with a single row, how do I convert it so it has the same dimensions of input image?