Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrating from 0.10 to 0.11, how to convert a ShortBuffer ? #141

Closed
lfdversluis opened this issue May 1, 2015 · 4 comments
Closed

Migrating from 0.10 to 0.11, how to convert a ShortBuffer ? #141

lfdversluis opened this issue May 1, 2015 · 4 comments
Labels

Comments

@lfdversluis
Copy link
Contributor

I am trying to convert my project from version 0.10 to 0.11.

I had this line in my project:

recorder.record(images[i % images.length]); and with the aid of a OpenCVFrameConverter.ToIplImage converter = new OpenCVFrameConverter.ToIplImage(); I could call recorder.record(converter.convert(images[i % images.length]));.

However, I also have a line where there is a ShortBuffer is used: recorder.record(imageSamples[i % imageSamples.length]);

Is there a way to convert a ShortBuffer to a Frame or IplImage ? Apparently the IplImage.createFrom(...); function no longer exists.

@vah13
Copy link

vah13 commented May 2, 2015

I have too this issue!

@vah13
Copy link

vah13 commented May 2, 2015

try {
frameGrabber.start();
opencv_core.IplImage tmp;
path = new String();
String file_name = video.substring(video.lastIndexOf("/") + 1).replace(".mp4", "");
tmp = frameGrabber.grab();
tmp = rotate(tmp, 90);
cvSaveImage(Environment.getExternalStorageDirectory().getAbsolutePath() + "/ss/temp/imagePreview.jpg", tmp);
path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/ss/temp/imagePreview.jpg";

        frameGrabber.stop();
    } catch (FrameGrabber.Exception e) {
        e.printStackTrace();
    }

Error:(55, 44) error: incompatible types: Frame cannot be converted to IplImage

@saudet saudet added the question label May 2, 2015
@saudet
Copy link
Member

saudet commented May 2, 2015

With the addition of FrameConverter, we would not be able to distinguish between recording video images or audio samples just with a single record(Buffer) function, so it was split in two:
public boolean recordImage(int width, int height, int depth, int channels, int stride, int pixelFormat, Buffer... image) (set the pixelFormat to -1 for the default)
public boolean recordSamples(int sampleRate, int audioChannels, Buffer... samples)

We can also create a new Frame() and assign the buffer to either the image[0] or samples[0] field, along with all the other required information, and call record(Frame).

@saudet saudet closed this as completed May 2, 2015
@saudet
Copy link
Member

saudet commented May 2, 2015

@vah13 Create a converter = new OpenCVFrameConverter.ToIplImage(), and call tmp = converter.convert(frameGrabber.grab());.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants