Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

java and matlab pixel value

Hi,

I have got a project in Matlab and I need to convert him to java. The project received a video file, decode him and o some manipulation on the frames.

My problem start in the decoding, I've got a different values of pixels. As example the first frame get the values(123,154,98) in the matlab but in eclipse I've got the values(120, 152, 96).

This is the first part of the matlab and java code that only read the first frame from the file: Matlab:

videoFReader = cv.VideoCapture(currFname);
    videoFReader.set('PosFrames' , startFrame-1); % 0 based numbering


    % Compute the cropping area

    % Initialize a zero matrix, which will contain the maximal gradient in each pixel
    max_G2 = 0; % In Matlab, we simply initialize it to 0, and it will becomse a matrix later.

    % For display purposes
    h = waitbar(0 , 'Computing Cropped Area');

    % Run on each of the relevant frames
    for cF = 1 : (endFrame - startFrame + 1)

        % For display purposes
        if mod(cF , 10) == 0, waitbar(cF / (endFrame - startFrame + 1) , h); end

        currFrame = videoFReader.read;}

Java:

for(int i = 0 ; i < FRAME_SIZE ; i++)
        {
                Mat mainMat = new Mat();
                b = retriever.getFrameAtTime((((i * 28))/30)*1000000,MediaMetadataRetriever.OPTION_CLOSEST);
                //b = retriever.getFrameAtTime(((630 + (i * 28))/30)*1000000,MediaMetadataRetriever.OPTION_CLOSEST);
                mainMat =  new Mat(new Size(b.getWidth(),b.getHeight()),CvType.CV_16UC3);

                Utils.bitmapToMat(b, mainMat);}

I'm sure that is the same frame cause I take the first frame.

What am I missing here?