EngnzWaks / javacv

Automatically exported from code.google.com/p/javacv
GNU General Public License v2.0
0 stars 0 forks source link

Access to byte array from the averaged object created by cvCalcEigenObjects #218

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create new IplImage with cvCreateImage(new CvSize(width, height);, 
IPL_DEPTH_32F, 1);
2. Call cvCalcEigenObjects passing the created image as the average object 
holder
3. Try to get a byte array from the image

What is the expected output? What do you see instead?
I expected the raw byte data from the image, but get a 0 length byte array

What version of the product are you using? On what operating system?
JavaCV build from 12.05.2012, OpenCV 2.4.0. OS is Ubuntu 11.10 32bit

Please provide any additional information below.
I can access the raw byte data from IplImages when created from video frames 
with:
   BufferedImage bufImg = image.getBufferedImage();
   ByteArrayOutputStream baos = new ByteArrayOutputStream();
   ImageIO.write(bufImg, format, baos);
   baos.flush();
   byte[] imgBytes = baos.toByteArray();
   baos.close();
but this process doesn't seem to work with IplImages created by 
cvCalcEigenObjects, namely the average object and the eigenvectors. My goal is 
to serialize the image and store/read it to/from a remote datastore (if it can 
be done some other way without accessing the raw data, please do point me in 
that direction).
I know the data is there somewhere, since I can create an image copy with 
createFrom(image.getBufferedImage()) and appears correctly when saved to disk...

Any help would be greatly appreciated

Ricardo

Original issue reported on code.google.com by rikycald...@gmail.com on 18 Jul 2012 at 5:04

GoogleCodeExporter commented 8 years ago
I think IplImage.getByteBuffer() as mentioned in the README.txt file does what 
you want. Let me know if not

Original comment by samuel.a...@gmail.com on 19 Jul 2012 at 2:23

GoogleCodeExporter commented 8 years ago
It did do what I wanted :) thank you

Original comment by rikycald...@gmail.com on 19 Jul 2012 at 11:09