|
About all you can do, is take a screenshot.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
It is probably better that you write your own code to be fair.
|
|
|
|
|
Set DocumentText to the HTML code, then draw it to a Bitmap. If you have the web URL the source code came from - even better. Navigate to that, then draw to a Bitmap as before
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
|
Hello Everyone-
I am looking at making an application that will detect the square footage of a piece of wood that is placed on a table. I am thinking that the table will have a bright orange color, so the dark wood placed on it would provide a lot of contrast. I will use a camera to take a picture of the table (the table lets say is 6 FT by 6 FT) and analyze the image to figure out how big the piece of wood is that has been placed on this table.
I am wondering if anyone can point me in the right direction here code wise (like search terms, etc). I've so far made it to Blob Analysis and have been reading about that. Any help or pointers into exactly what I need to learn to make this possible would be appreciated immensely!
Thank you!
EDIT: I also am wondering if it would be possible to somehow equate each pixel with a real life measurement, such as 1mm, and if it was possible to somehow calculate the pixels that were not orange, and come up with a measurement that way (Because some times the pieces of wood are not going to be square or rectangular ... but I figured I would get the sq/rect down first because I just figured that would be the easiest). I'm in the middle of reading an awesome multi-part article on this site about it, but just trying to figure out which way to go next.
Thanks much!
modified on Thursday, July 9, 2009 9:42 AM
|
|
|
|
|
Hey,
is this the same[^] you are looking for ?
Thanks,
Sun Rays
To get something you must have to try once.
My Articles
|
|
|
|
|
Hi There-
That is the article that I am reading now! What I am trying to do is figure out how to take the edge detection from that article and apply it into my solution (ie, somehow take the edges and do some calculations to figure out the square footage). That's kind of where I am stumped, I don't know how to "link" the two.
Thank you!!
|
|
|
|
|
Basically, the edge detection filters will give you a high contrast result, which you can iterate over and find edges easily, because they are close to white, while the rest is basically black. The real issue is, knowing for sure that there's only two objects with edges in your image. I've done this sort of thing before, to calibrate the size of a photo in an xray scanner, so I could them measure other images. We scanned a sheet which had a series of dots on it. I didn't use any filters, I just walked the image looking for black pixels. Once this was done, we used the mapping of pixels to mm to provide measurements in a measure tool inside the software.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
First of all, your article series is AWESOME and I thank you for it as well as the help you've given me over the past few weeks!
I am wondering if this scenario would work. Your input would be greatly appreciated! The camera is set to produce a 1024x768 image. The camera looks down onto a table that is 10' by 10' (100 Square Feet). I position the camera so that the image it captures exactly covers this table. The table is painted a bright orange color (R-255,G-162,B-59). (Now I'm just trying to work this out in my head, I don't know if this will work, but what I am thinking is...)
The camera is looking on the table, so we know that the 1024x768 image that the camera is going to produce will cover exactly 100 Square Feet, every time. So, a grand total of 786,432 pixels. 100 Square Feet would be 30,480 sq millimeters. Each pixel would equate to approximately 0.03875732421875 of a millimeter. (I don't know if this is correct or logical or would work I'm just thinking out loud).
I open up the image. I walk through the image using GetPixel, pixel by pixel, and check the RGB value of that pixel. If it is close to 255/162/59, i disregard it. Any other color would add the 0.038... number to the global count. After it is all said and done, I should have a value of how many millimeters in the entire space is "in use" and be able to calculate the total area of the wood or stones that are currently on the table.
Basically a family member contacted me. He sells stone (they may be mosaic, so not necessarily always rectangular). I'm trying to think of a way to take pictures of the stone as he puts them into a bin in order to calculate the square footage on those stones that he is selling (ie, he sold 250 SQ feet to someone "by eye" and the person actually got out a measuring tape and measured all the pieces and realized there was only 240 SQ feet and had a hissy). So I was thinking if this method of analyzing an image pixel by pixel, when you know exactly how big the area is every time of that image, would work.
Thanks much for the response!!
|
|
|
|
|
It sound logical, but you would get a different result depending on how the stone / wood is oriented. Instead of using the whole image, just use a 768 * 768 portion of it, and each pixel can then be square (and 3.96875mm on a side, so your size calculation is a little iffy - 10 feet = 3048mm so 100 sq feet would be 3048 * 3048 sq mm).
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
I'm not sure whether Microsoft provides WMI providers for Microsoft Exchange Server 2010.
If yes how do I get this information. I basically wish to get the device information regarding where the exchange db is deployed upto a .eml file.
Another facet of this query is this information from WMI provider needs to go into an XML that could be understood by may be classes that ADo provide. Is there any relation between the info and how ADO can manage the XML coming.
To add I'm thinking of leveraging a ADO classes that are leveraged for Exchange in terms of getting datasets, connections, authentications. This is turn shall call the WMI interfaces which will respond with the relevant data.
If not if there anything one can suggest for prior versions of Exchange.
|
|
|
|
|
I am setting a PictureBox.Image to an ImageList index with
summaryKeyEventsPictureBox.Image = keyEventIconsImageList.Images[2];
If I wanted to test if my current pictureBox image was equal to the ImageList.Images[2] how would I do this please?
|
|
|
|
|
There's no equals operator for images. The most effective way, is to store the index somewhere. Does the picturebox have a Tag property ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi,
check this..[^]
may it helps you
Thanks,
Sun Rays
To get something you must have to try once.
My Articles
|
|
|
|
|
This is pretty close to being totally unrelated to his question
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
He meant well.
Anyway, my grateful thanks for all the replies.
|
|
|
|
|
ROTFL
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
As an addendum to what CG was saying you could also save them to MemoryStreams and hash them. From there, it's a simple matter of comparing the byte arrays. I wouldn't personally use this method, I'm just including it for completeness' sake. I would do as CG said, and try to use the PictureBox's Tag property
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Hi,
I'm trying to encrypt a string in c# that would be decrypted with perl. The problem is that in the perl script there is not IV specified so, when I encrypt the result is not readable be the perl decryptor.
Is there any workaround to know who perl auto generate the IV (I suppose that's what it does) ?
C# Code to Encrypt :
private string strCryptoMessage(string strOrig, string strKey)
{
System.Security.Cryptography.RijndaelManaged rj = new System.Security.Cryptography.RijndaelManaged();
rj.Mode = System.Security.Cryptography.CipherMode.CBC;
rj.Key = Encoding.UTF8.GetBytes(strKey);
byte[] bOrig = Encoding.UTF8.GetBytes(strOrig);
System.IO.MemoryStream ms = new System.IO.MemoryStream();
System.Security.Cryptography.CryptoStream cs = new System.Security.Cryptography.CryptoStream(ms, rj.CreateEncryptor(), System.Security.Cryptography.CryptoStreamMode.Write);
cs.Write(bOrig, 0, bOrig.Length);
cs.FlushFinalBlock();
string bResult = Convert.ToBase64String(ms.ToArray());
ms.Flush();
return bResult;
}
Perl Code To Encrypt :
#!/opt/local/bin/perl -w
use IO::Socket;
use IO::Handle;
use MIME::Base64;
use Data::Dumper;
use POSIX;
use Getopt::Long;
use strict;
require Crypt::CBC;
my $msg = "MESSAGE_TO_ENCRYPT";
my $enc_key = "SAME_AS_strKey";
my $enc_alg = "Rijndael";
my $cipher = Crypt::CBC->new({
'key' => $enc_key,
'cipher' => $enc_alg,
});
my $encrypted_msg = $cipher->encrypt($msg);
print "$msg\n";
my $encoded_msg = encode_base64($encrypted_msg, '');
print "$encoded_msg\n";
Both should generate the same result, but I think that the perl Crypt::CBC generate the IV code using the key in some way.
|
|
|
|
|
I want to do a tile by myself, I can see that the result image is very blurry, and the positions of each piece are not correct(overlapped partly), why?
Bitmap bitmap = new Bitmap(2000, 2000, PixelFormat.Format32bppArgb);<br />
using (Graphics graphic = Graphics.FromImage(bitmap))<br />
{<br />
Bitmap image = (Bitmap)Bitmap.FromFile(@"background.bmp");<br />
for (int j = 0; j < 15; j++)<br />
{<br />
graphic.DrawImageUnscaled(image, (j % 4) * image.Width, (j / 4) * image.Height, image.Width, image.Height);<br />
}<br />
}<br />
bitmap.Save(@"a.png", ImageFormat.Png);<br />
Regards,
unruledboy_at_gmail_dot_com
http://www.xnlab.com
|
|
|
|
|
The images overlap because your code causes them to. To tile properly, just do j* width and j * height. You can also create a texturebrush which uses the bitmap and tiles, and then just fill the rectangle with that brush
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
hi, if I only do j*width and j*height, won't it only be tiling from top left to bottom right(diagonally)?
and, it seems that the blurry problem only goes with some bmp files, strange
by the way, I actually want to title all the pictures(not only one) in one picture, something like mosaic, so, texture brush maybe not suitable.
Regards,
unruledboy_at_gmail_dot_com
http://www.xnlab.com
|
|
|
|
|
Hello there. I'm trying to detect which character is produced whenever the user presses a key. For this, I'm using the ToUnicodeEx function, which translates the specified virtual-key code and keyboard state to the corresponding Unicode character, inside a keyboard system wide hook. However, every time the user presses dead keys, such as the ones producing '¨', '~' or '´', strange things happen. Here is sample code of the first version:
private static int KeyboardHookProc(int nCode, Int32 wParam, IntPtr lParam)
{
bool handled = false;
if (nCode >= 0)
{
KeyboardHookStruct MyKeyboardHookStruct = (KeyboardHookStruct)Marshal.PtrToStructure(lParam, typeof(KeyboardHookStruct));
if (s_KeyPress != null && wParam == WM_KEYDOWN)
{
bool isDownShift = ((GetKeyState(VK_SHIFT) & 0x80) == 0x80 ? true : false);
bool isDownCapslock = (GetKeyState(VK_CAPITAL) != 0 ? true : false);
byte[] keyState = new byte[256];
GetKeyboardState(keyState);
System.Text.StringBuilder sbString = new System.Text.StringBuilder();
IntPtr HKL = GetKeyboardLayout(0);
switch (ToUnicodeEx((uint)MyKeyboardHookStruct.VirtualKeyCode,
(uint)MyKeyboardHookStruct.ScanCode,
keyState,
sbString,
5,
(uint)MyKeyboardHookStruct.Flags,
HKL))
{
case 1:
char key = sbString.ToString()[0];
if ((isDownCapslock ^ isDownShift) && Char.IsLetter(key)) key = Char.ToUpper(key);
KeyPressEventArgs e = new KeyPressEventArgs(key);
s_KeyPress.Invoke(null, e);
handled = handled || e.Handled;
break;
}
}
}
if (handled)
return -1;
return CallNextHookEx(s_KeyboardHookHandle, nCode, wParam, lParam);
}
With this code I faced the following problem: Whenever I tried to type "á" in notepad, which requires '´' to be pressed before 'a', the result would be "´´a". Although the captured character by ToUnicodeEx was 'á', I can't admit that my application prevents the user from using characters such as 'á'.
So, I worked around this problem by avoiding ToUnicodeEx to be called whenever a dead key is pressed. This way, I can avoid the ToUnicodeEx function from messing with the keyboard state. Here is the current version code:
private static int KeyboardHookProc(int nCode, Int32 wParam, IntPtr lParam)
{
bool handled = false;
if (nCode >= 0)
{
KeyboardHookStruct MyKeyboardHookStruct = (KeyboardHookStruct)Marshal.PtrToStructure(lParam, typeof(KeyboardHookStruct));
if (s_KeyPress != null && wParam == WM_KEYDOWN)
{
bool isDownShift = ((GetKeyState(VK_SHIFT) & 0x80) == 0x80 ? true : false);
bool isDownCapslock = (GetKeyState(VK_CAPITAL) != 0 ? true : false);
byte[] keyState = new byte[256];
GetKeyboardState(keyState);
System.Text.StringBuilder sbString = new System.Text.StringBuilder();
IntPtr HKL = GetKeyboardLayout(0);
if (!IsDeadKey((uint)MyKeyboardHookStruct.VirtualKeyCode))
{
switch (ToUnicodeEx((uint)MyKeyboardHookStruct.VirtualKeyCode,
(uint)MyKeyboardHookStruct.ScanCode,
keyState,
sbString,
5,
(uint)MyKeyboardHookStruct.Flags,
HKL))
{
case 1:
char key = sbString.ToString()[0];
if ((isDownCapslock ^ isDownShift) && Char.IsLetter(key)) key = Char.ToUpper(key);
KeyPressEventArgs e = new KeyPressEventArgs(key);
s_KeyPress.Invoke(null, e);
handled = handled || e.Handled;
break;
}
}
}
}
if (handled)
return -1;
return CallNextHookEx(s_KeyboardHookHandle, nCode, wParam, lParam);
}
static bool IsDeadKey(uint key)
{
if ((MapVirtualKey(key, 2) & 2147483648) == 2147483648)
{
return true;
}
else
{
return false;
}
}
I though this solution would solve my problem, but I was wrong. The result has improved, but it's not quite what I wanted. Now, typing 'á' in notepad results in 'a'. Notice that the accent '´' is missing.
Does anyone know how to work around this issue? My current method already captures the correct character, but prevents the user from producing characters with accents or diacritics. I think the KeyboardHookProc method just need a few changes, but I can't figure them out.
Thanks in advance.
PS: I tried the solution described in the following link: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/7c038b72-3ae3-4b9e-9e21-33c7ccea735c. However, the result is quite the same as in my current version. That code only erases the keyboard buffer, which deletes the accents, therefore not allowing the user to use them.
|
|
|
|
|
Hi am try to write an inventory software, i want to interface that software with a cash register so that i can account for sale made .i want to know how i can read data from the cash register pls help me.u can specify the cash register that i might be easy to use pls help ASAP
if(me){
throw new Exception("hello there");
}
|
|
|
|
|
What are you asking for ? Do you have a cash register ? Do you plan to buy one, based on what someone suggests here ? Do they have google where you live ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|