You Are Here:

Community: Developer Discussion Boards

#1 Old Capturing pixels 3650 / 7650 - 2003-09-27, 13:40

Join Date: Mar 2003
Posts: 23
blackjack75
Offline
Registered User
Is it possible to capture a raw video stream from nokia 3650 / 7650.

I have read in posts that symbian applications can do it (they capture the stream and compress to mpeg) but is it possible with Java?

Is it possible to obtain a bytearrayinputstream using a locator like:
capture://video?encoding=gray8&width=160&height=120

as described in the MIDP 2.0 MMAPI doc:
http://bf.monis.ch/prog/java/midp/midp-2-mmapi/

In the case it's not (Which I fear) what's the format of the BMP the getsnapshot() method returns? Does it use any compression or is ia a plain rgb file with a simple header I can just skip?

Finally, about speed. If I have to use the latter method would you consider possible on a 3650 or 7650 to capture at 15 fps using a loop of getSnapshot(). ?

BTW, I do not intend to display or keep the image anywhere, just capture it, analyze it's pixels and trash it.

Thanks for your help!
Reply With Quote

#2 Old Anyone? Help - 2003-10-06, 01:01

Join Date: Mar 2003
Posts: 23
blackjack75
Offline
Registered User
Did anybody ever do this ?
Reply With Quote

#3 Old Implementation of getRGB() - 2003-10-24, 10:46

Join Date: Sep 2003
Posts: 25
JTierno
Offline
Registered User
I had the same problem when trying to convert a midp2.0 application (for a 6600) to midp 1.0 for a 3650. In Midp2.0 we have the Image.getRGB() method, wich returns an array of ints with the RGB values of the pixels.

As you know, this does not exist in midp1.0, so I had to implement myself something of the like. What I did is get a byte array with the png image with getSnapshot(null), And then obtain the pixel values from there.

This is quite easy as, fortunately, the image returned by the camera (not by the simulator, which returns just the image as you put it, as you know) is neither compressed, interlaced nor filtered, so all I had to do was take the headers out.

Well besides of the png header, we have a deflate header at the beginning of every scanline of the image (a Png-format image contains zip-format data, with contains deflate-format data. Don´t worry, as I said above, nothing is compressed, it´s only headers. It is all documented at www.libpng.org), and also the byte for the filter of the line. Just ignore this and get the pixel values.

It´s a clumsy solution, but it works. You may find all the information about png format at www.libpng.org, but better, try first with the bmp format with getSnapshot("encoding=bmp"), this may be simpler (I thought of this after I had finished with the method in png format...).
Reply With Quote

#4 Old Thanks - 2003-10-24, 13:02

Join Date: Mar 2003
Posts: 23
blackjack75
Offline
Registered User
Hi JTierno,

thanks for your help. We'll get on it then! How many fps do you get with the such technique (skipping the headers) ?

Yup, I thought about BMP rather than png since it is indeed much simpler. I suspect the phone can do snapshots at a decent speed with this.

Do you think it is possible to call getSnapshot() at about 15 fps on a 3650? Or is it hopeless?

Thanks for your help
Reply With Quote

#5 Old No idea about fps - 2003-10-24, 13:46

Join Date: Sep 2003
Posts: 25
JTierno
Offline
Registered User
Sorry, I don´t know much about speeds, as my application is not real-time. I just get an image on user´s demand and process that single image.

But I don´t think it is hopeless, I´d give it a try.

Good luck.
Reply With Quote

#6 Old Regarding PNG format - 2004-02-25, 22:39

Join Date: Feb 2004
Posts: 1
manohsunil
Offline
Registered User
Hi,

I am taking a snapshot from Nokia 3650 and storing it in the BYTE array. I have the

following doubts :-

1) is the data in the BYTE array COMPRESSED ?

2) Will EACH LINE of PNG image have HEADERS ? because I visited the www.libpng.org and

there they said that ALL DATA is between the IDAT & IEND header chunks.

is this information correct ?

Kindly do clear my doubts. Hoping to hear from you.

Yours Sincerely,
Sunil Manoharan
Reply With Quote

#7 Old 3650 snapshot - 2004-02-26, 10:07

Join Date: Sep 2003
Posts: 25
JTierno
Offline
Registered User
I have replied this already by mail, but in case somebody else is interested.

The data is all contained in one only IDAT chunk, but each scanline is packed inside its own Deflate block, So every line has a header (And also a filter byte). However, the data block is not compressed: The deflate header indicates zero compression.

Here is the code I use to extract the rgb values of an image. I extract the fields of the header one by one, but do nothing with them, just skip:

void getRGB(byte in[], int out[]){

int chunklen;
byte fourbytes[] = new byte[4];
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(in));
int offset = 0;
int width=0,height=0;
String chunkName = null;

StringBuffer sb;

try{
//read PNG sign
stream.skip(8);


while( true ){
//length
chunklen = stream.readInt();

if (chunklen < 0) throw new IOException("Parsing Exception reading chunk length");

//type
if ( stream.read(fourbytes) == -1) throw new IOException("Parsing Exception reading chunk type");
chunkName = new String(fourbytes);

// Data

//IHDR: first Chunk
if (chunkName.equals("IHDR")){

width = stream.readInt();
height = stream.readInt();

if (width*height != out.length) throw new IOException("sizes do not match:");
if (stream.readByte() != 8) throw new IOException("bit depth not supported");
byte b = stream.readByte();

//compression
b = stream.readByte();

//filter method
b = stream.readByte();

//Interlace method
b = stream.readByte();

}


//IEND: last Chunk
else if (chunkName.equals("IEND")){
//System.out.println("IEND chunk!");

break;
}

//IDAT: image data
else if (chunkName.equals("IDAT")){
System.out.print("IDAT chunk... ");
stream.read(data,offset,chunklen);

offset += chunklen;


}

//Any other chunk is not parsed: skip data
else if (stream.skip(chunklen) != chunklen) throw new IOException("Parsing Exception reading unused chunk");

//CRC
if(stream.skip(4) == -1) throw new IOException("Parsing Exception reading CRC");

}

stream.close();

//Read data inside IDAT Chunk

stream = new DataInputStream(new ByteArrayInputStream(data));

//Code
stream.readByte();

//flags
stream.readByte();

//Deflate header
stream.readByte();

byte header;
int len, nlen;
byte filter;

//Read each scanline

for (int i = 0; i < height; i++)
{
header = stream.readByte();
if ( (header & 6) != 0)
{
throw new IOException("incorrect deflate header");
}

if (i == height-1 && (header & 1) != 1)
{
throw new IOException("incorrect last deflate header");
}

len = (int)stream.readUnsignedByte()+256*(int)stream.readUnsignedByte();
nlen = (int)stream.readUnsignedByte()+256*(int)stream.readUnsignedByte();

//LEN & NLEN header fields
if (len + nlen != 65535){
form.append("\nLEN: ");
form.append(new Integer(len).toString());

form.append("; NLEN: ");
form.append(new Integer(nlen).toString());

throw new IOException("nlen != one´s complement!");

}

//Filter type
filter = stream.readByte();
if (filter != 0)
{
form.append("\nFIlter: ");
form.append(new Byte(filter).toString());

throw new IOException("filter present");
}
if (width != (len-1)/3) throw new IOException("Incorrect width");


for (int j=0; j<width; j++)
{
out[width*i+j] = ((int)stream.readUnsignedByte())<<16 | ((int)stream.readUnsignedByte())<<8 | (int)stream.readUnsignedByte();
}

}

//ADLER 32 checksum.

if (stream.skip(4) != 4) throw new IOException("Incorrect Checksum");
stream.close();


}
catch(IOException ioe){
System.out.print("IOException: ");
System.out.println(ioe.getMessage());
}
}

I hope this is of some help.
Reply With Quote

#8 Old 2005-04-30, 15:58

Join Date: Apr 2005
Posts: 2
mooflon
Offline
Registered User
When give do this :
getSnaphot(encoding=gray8)
I take some Exception

Question : how can i get an image with gray8?
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d18645X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ