Choosing between two methods of screen capturing in C# - c#

The purpose of my Program is to capture multiple areas on the screen. I'm choosing between 2 methods to write this program:
Making one big screenshot 800x600 for further cropping (10+ areas)
Or making multiple Small screenshots with given coordinates. (10+)
what's better in terms of performance?
another question which is also related to this question is:
where do I keep all crop coordinates? I'll need at least one Column to specify numbering, Next two columns will have X and Y coordinates and last two - W and H. I was thinking about making a dictionary for a separate crop.. or maybe a table, SQL, INI, array ?? that's the second question. Easiness of use and performance are top priorities.
thanks
Edit: Rephrasing the question. What's faster - To capture a screenshot of whole screen and Crop it into 100 small areas (W:10 & H:100) OR to capture 100 small Screenshots without the need to crop anything?

The answer is to measure this. We can't know the answer without trying. It also probably depends on the exact count and sized of the screenshot areas.

Related

Split image in parts

I want to be able to reproduce something like this image (taken from NBA.com )
What I have :
- A court with the white lines
- A list of Position for each shot and I know if they are made or missed.
But I'm stuck on the method to realize the image :
Should I create images for each part of the field using photoshop/paint.net and then color it in c# ?
Of course the best way would be to have an equation for each part so I can check easily if the position is in and I could also draw it.
How would you do it ?
You need to first decide on how replicable you need the solution. If you need it for a 1-10 pictures, then don't bother with code- it will most surely take much longer to fine tune it.
If was to work on this specific image, I would probably take my time to find expressions for all lines to make calculations more precise though.

Draw a graph using arrays of pictureboxes

I am currently writing a program where I need to draw some graph's. I need to have a little bit specific layout in these graphs. For example I have three stages of a length in days defined by the user. a start stage of for example 30 days, a mid stage of 40 and an end stage of 20 days. These stages I want to have all a different backgroundcolor in the graph. I do that by drawing pictureboxes and adapting their widths to the stage lengths. Also for every day in the total length I want to draw a vertical line and for the amount of horizontal lines in the graph I take the maximum of y = f(x).
y = f(x) needs to be plotted on the graph. For I use many pictureboxes on the background I cannot use the graphics.DrawLine for it will be drawn behind the pictureboxes. So I decided to make the line with an array of pictureboxes ;) It works fine, but obviously it takes a lot of time to load the program now.
Is there another way to draw this graph using arrays of controls that require less effort from the computer? Or should I completely stop with the arrays?
(I wanted to post my picture here, but I don't have ten reputation yet because I'm a noobie :( )
Later on I will add more lines to this graph, but since I figured that my program is already slowing down I ceased programming those other lines and went to the all-knowing forum!
Any help will be much appreciated!
Greetz,
Arrie
The common form controls aren't really suitable for this purpose. I'd suggest taking a look at using libraries that give you more power and control over visuals and graphics.
#Kári is right:
If you want to stay with .NET only (no 3rd library dependence) you can use GDI. In .NET you can use by including System.Drawing.dll as an reference.
One simple yet correct approach would be:
create a target control (picturebox for example)
implement the OnPaintDraw Event which gives you an Graphics object
that contains many drawing methods. See MSDN for more information:
MSDN -> Graphics
The methods of Graphics will always draw above the control, so make sure your target control is visible an not behind any other control.
If GDI is not enough you can check out other libraries. (See .NET graph library around?)

AForge.NET Compare and find Blobs(Connected Components) in two images

I want to use AForge.NET library to examine similiar images and to localize the differences. I can imagine the following algorithm.
a. Compare 2 images, generate as result binary image with white pixels for differences and black pixels for matches.
b. Use BlobCounter for searching of the connected pixels.
What filter can be used for a)? How to count the pixels in each Blob ?
Take a look at my previous answer here Aforge Blob Detection
For A), you can use the ThresholdDifference, this will give you black pixels when there are no changes and white pixels when there is a difference. You can invert this with a Image>Invert (http://www.aforgenet.com/framework/docs/html/458e1304-0858-ae29-113f-e2ec9072c626.htm)
As for B), you can use Connected Component Labeling (see the post), this will give an approximate width and height of the objects. If you want count exactly how many pixels are different you will probably need to write an procedure for this. It is not very difficult, it is just a two nested For cycle that will go over each X, Y pixel and then will increase a counter every time it finds an specific color on it.

Image OCR - Filtering unwanted data

Basically I'm reading vehicle license plates using tessract OCR, however despite being able to emphasise text easily enough via changing contrast, reducing noise an so on, some 'parts' of the vehicle remain on the image which does cause the OCR to throw bad results.
For example take:
I can change this easily enough, such as:
I'm looking to eliminate the edges off each plate, here's another example:
I could remove the edges using pixel manipulation algorithm, however I don't feel it's the right method, and would cause quite a lot of problems.
I've been using the following application to test various methods such as morphology and eliminating the unwanted data, so far I haven't been successful.
http://www.codeproject.com/KB/GDI-plus/Image_Processing_Lab.aspx
However someone with knowledge of this could use the application on the article above to achieve want I'm trying, so feel free to give it a try.
Thanks
Please try to use stroke width transformation concept.
This concept use to segment text from natural images.....
I already did such an algorithm. I just can say that it works great. The secret is, that you need to know that the light is coming just from one side perhaps. You cannot set the image to "black/white" just by using ONE threshold.
Detect the average luminance of parts of the image and use this luminance calculation to set the threshold for each region.
For example, if the left top is lighter, you need a lower threshold to make these parts not to bright. And if the bottom right has low light, you need to set the threshold higher to receive all existing light information.
Then, you need just to drive into the image from each side by using the method:
IsPixelAboveThreshold ?
If it is below, you are on the border, if it is above, you can say you are on the middle of the image with more brightness.
Regards

What is the best algorithm to locate a point in an image file?

I want to create a mark sheet recognizer.
Here is the description:
My system uses black and white color scheme.
The mark sheet paper has a small black rectangle on each corner and an additional small black rectangle, to determine orientation, near one of the previous rectangles.
The paper is scanned to yield an image (in bmp format for example).
The first step is to locate these five references in image as eficient as possible.
My rough idea is to trace row by row and from left to right for each row.
It sounds very slow I think.
Is there any better way to do that?
Thank you in advance.
regards,
Suugaku
You can start by searching where you typically expect to find the reference images. You can do this by keeping statistics of where they were before. In particular if you have two frames taken one after the other, the chances are the reference points won't have moved very far.
Once you have found one or more of the reference points, the position of the others becomes heavily constrained so you can make a very good guess as to where the others must lie. Each time you find a new point it provides more hints as to where the remaining points can be.
So you can start by using a bit of guesswork to find the points quickly, and revert to a line-by-line scan if that fails.
Speed is not an issue if you use the BitMap.LockBits() instance method (https://web.archive.org/web/20121203144033/http://www.bobpowell.net/lockingbits.htm). Then, all you need is a couple of hours.

Categories