473,508 Members | 2,298 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting byte size of image

I am trying to come up with a focussing routine for a camera and I need to
detect when the image is in focus.

As I understand it, JPG Image size goes up sharply when it is in focus as it
is very sensitive to the presence of sharply defined edges (high spatial
frequency information). I have the following routine which gets the image
from the camera into NewPic. I am trying to find the size in bytes of this
image and I don't want to write it out to disk and read it again. I have
looked at various properties of NewPic and also respStream and I can't find
the answer.
Dim siteUri As New System.Uri(URL)
WebRequest = System.Net.WebRequest.Create(siteUri)
WebRequest.Timeout = 3000
Dim respStream As System.IO.Stream = Nothing
Dim webResponse As System.Net.WebResponse = WebRequest.GetResponse()
respStream = webResponse.GetResponseStream()
Dim NewPic As Image = Image.FromStream(respStream)

-Jerry
Apr 19 '07 #1
2 4534
Jerry Spence1 wrote:
I am trying to come up with a focussing routine for a camera and I need to
detect when the image is in focus.

As I understand it, JPG Image size goes up sharply when it is in focus as it
is very sensitive to the presence of sharply defined edges (high spatial
frequency information). I have the following routine which gets the image
from the camera into NewPic. I am trying to find the size in bytes of this
image and I don't want to write it out to disk and read it again. I have
looked at various properties of NewPic and also respStream and I can't find
the answer.
Dim siteUri As New System.Uri(URL)
WebRequest = System.Net.WebRequest.Create(siteUri)
WebRequest.Timeout = 3000
Dim respStream As System.IO.Stream = Nothing
Dim webResponse As System.Net.WebResponse = WebRequest.GetResponse()
respStream = webResponse.GetResponseStream()
Dim NewPic As Image = Image.FromStream(respStream)

-Jerry
If you can't get the length from the WebResponse object, you can write
the stream to a MemoryStream.

--
Göran Andersson
_____
http://www.guffa.com
Apr 19 '07 #2
Webresponse was the answer. Thanks very much Göran

-Jerry
"Göran Andersson" <gu***@guffa.comwrote in message
news:OL**************@TK2MSFTNGP03.phx.gbl...
Jerry Spence1 wrote:
>I am trying to come up with a focussing routine for a camera and I need
to detect when the image is in focus.

As I understand it, JPG Image size goes up sharply when it is in focus as
it is very sensitive to the presence of sharply defined edges (high
spatial frequency information). I have the following routine which gets
the image from the camera into NewPic. I am trying to find the size in
bytes of this image and I don't want to write it out to disk and read it
again. I have looked at various properties of NewPic and also respStream
and I can't find the answer.
Dim siteUri As New System.Uri(URL)
WebRequest = System.Net.WebRequest.Create(siteUri)
WebRequest.Timeout = 3000
Dim respStream As System.IO.Stream = Nothing
Dim webResponse As System.Net.WebResponse = WebRequest.GetResponse()
respStream = webResponse.GetResponseStream()
Dim NewPic As Image = Image.FromStream(respStream)

-Jerry

If you can't get the length from the WebResponse object, you can write the
stream to a MemoryStream.

--
Göran Andersson
_____
http://www.guffa.com

May 2 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
1492
by: Eric | last post by:
I have an array that contains over 30000+ bits. The size varies at runtime. I need to move through this chunk of memory and count bits every so often. Example: First 9 bits has 2 ones, next 10...
16
16388
by: Khuong Dinh Pham | last post by:
I have the contents of an image of type std::string. How can I make a CxImage object with this type. The parameters to CxImage is: CxImage(byte* data, DWORD size) Thx in advance
2
4277
by: Li Zhang | last post by:
I have a problem with reading byte from a memory stream. Basically I want to resize a image and then store them to sql server. Here is part of the codes. every time I tried to read byte from...
3
3055
by: Hitesh | last post by:
Hi, I am getting the response from another Website by using the HttpHandler in my current site. I am getting the page but all the images on that page are not appearing only placeholder are...
1
10077
by: sympatico | last post by:
Hi, I am trying to compare 2 images to check if they are exactly identical (in terms of data), I thought this would be quicker than analysing pixels of the images. I have found lots of examples...
8
11632
by: piggy | last post by:
I am trying to convert an image to an byte array (tobytes() method) and from byte array back to an image (frombytes() method). The problem i have here is say the image size is 285 bytes but the...
23
16342
by: Gerrit | last post by:
Hi all, I'm getting an OutOfMemoryException when I initialize a byte array in C# like this: Byte test = new Byte; I'm using ASP.NET 2.0. In ASP.Net 1.1 it works fine. So what am I doing...
1
9286
by: | last post by:
Hi all, I am writing a sendmail milter application in Java. The incoming mails will usually have image file as attachments. My application is currently able to extract the ImageFile and save it...
1
2212
by: Stephen.Schoenberger | last post by:
I am working with some images as byte arrays and am not sure nor can I figure out if as I am reading the image and saving smaller sub- images I am reading across and down the image or down and back...
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7123
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7382
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7042
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7495
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3193
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1556
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.