473,569 Members | 2,422 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.WebR equest.Create(s iteUri)
WebRequest.Time out = 3000
Dim respStream As System.IO.Strea m = Nothing
Dim webResponse As System.Net.WebR esponse = WebRequest.GetR esponse()
respStream = webResponse.Get ResponseStream( )
Dim NewPic As Image = Image.FromStrea m(respStream)

-Jerry
Apr 19 '07 #1
2 4549
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.WebR equest.Create(s iteUri)
WebRequest.Time out = 3000
Dim respStream As System.IO.Strea m = Nothing
Dim webResponse As System.Net.WebR esponse = WebRequest.GetR esponse()
respStream = webResponse.Get ResponseStream( )
Dim NewPic As Image = Image.FromStrea m(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.co mwrote in message
news:OL******** ******@TK2MSFTN GP03.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.WebR equest.Create(s iteUri)
WebRequest.Tim eout = 3000
Dim respStream As System.IO.Strea m = Nothing
Dim webResponse As System.Net.WebR esponse = WebRequest.GetR esponse()
respStream = webResponse.Get ResponseStream( )
Dim NewPic As Image = Image.FromStrea m(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
1499
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 bits has 4 ones, next 9 bits has 8 ones ... I know the number of bits that need to be counted at runtime only. But I do know it will be two...
16
16399
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
4282
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 stream, I only got all 0 byte, I don't know what is the problem. Please help me to check my error. Thanks. httpImageFile = imageFile.PostedFile;...
3
3067
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 displayed. Can anybody know this issue and help me to resolve this. In past i received the response saying that i should download the image first...
1
10107
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 for encrypting text strings using MD5 hash, but I cannot find a way to get this to work with images that exist in picture boxes. I am trying to get a...
8
11641
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 total bytes is 635. I know it would include the header but the header should be the same size regardless of the image size. I tested the other image...
23
16369
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 wrong?
1
9294
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 on the filesystem. This part is working perfectly. ((MimeBodyPart)p).saveFile(new File(p.getFileName())); However, I would like to pass this...
1
2222
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 up or randomly? I need to know so in turn I can realize what the coordinates are of the sub-images. Here is a snippet of the code that is...
0
7703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8132
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7678
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7982
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3656
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
944
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.