Hello,
not really sure if this is the correct place to ask this, but here goes:
I'm currently working on an application that uses the client-server model to accomplish the following:
- The server grabs images from camera's and stores them on disk.
- The server application talks to the grabber software and obtains the absolute path to the bitmap files.
- The client asks the server application for an image and gets it in jpeg.
The idea behind this is to simulate a videostream by delivering the images in sequence fast enough. Currently I'm encountering the following issues:
- FPS is only 2, I think i'm loosing alot of overhead in the TCP traffic.
- Server goes up to 100% load. My believe is that the altering of bitmap -> jpeg sucks up all available resources.
I'm basicly looking for some guides or information about image processing and client-server architecture. The application is written in C# and relies in .NET 4.0.
I can provide the test application or parts of the code. -
// Cast the data we recieved to a string.
-
string message = Encoding.ASCII.GetString(data);
-
-
// Check if we have an @CAMNR message
-
if (message.Contains("@CAMNR:"))
-
{
-
Invoke(new MethodInvoker(delegate { m_debug.Items.Add("message recieved : " + message); }));
-
-
// Strip the last symbol and the @CAMNR: part.
-
message = message.Substring(7, (message.Length - 1) - "@CAMNR:".Length);
-
-
WriteMessage("stripped message : " + message);
-
-
// Load the image.
-
Image img = Image.FromFile(message);
-
-
// Load the image into a memorystream.
-
MemoryStream fullstream = new MemoryStream();
-
MemoryStream image_stream = new MemoryStream();
-
-
// Load the image into the image_stream buffer.
-
img.Save(image_stream, System.Drawing.Imaging.ImageFormat.Jpeg);
-
-
// Create the byte arrays that represent the header tag and the size.
-
byte[] header = Encoding.ASCII.GetBytes("@IMG:");
-
byte[] size = BitConverter.GetBytes(((int)image_stream.Length)); // Assume ints, since we only need 4 bytes.
-
-
//DEBUG
-
WriteMessage("File size according FileInfo class: " + new FileInfo(message).Length.ToString() + " bytes.");
-
WriteMessage("File size according Array Length: " + image_stream.Length.ToString() + " bytes");
-
WriteMessage("File size as int representation : " + ((int)image_stream.Length).ToString() + " bytes");
-
-
// Append the data to the memorystream.
-
fullstream.Write(header, 0, header.Length);
-
fullstream.Write(size, 0, size.Length);
-
fullstream.Write(image_stream.ToArray(), 0, image_stream.ToArray().Length);
-
-
WriteMessage("Image loaded into the memorystream.");
-
-
// Convert the entire memorystream into an byte array.
-
byte[] buffer = fullstream.ToArray();
-
-
// Start pumping out the data over the network socket. This will be done in several bursts depending
-
// on the settings of the network.
-
m_client.GetStream().Write(buffer, 0, buffer.Length);
-
-
WriteMessage("Image send to client.");
-
}
-
This is the code that I use to respond on a image request. It loads the bitmap, turns it into a jpeg and delivers it to the client. My guess is, that the biggers overhead problem exists here already, but this sort of uncharted teritory for me.
12 1489 Oralloy 988
Recognized Expert Contributor
Well, if the server load is 100%, I can almost guarantee that your 2FPS is not due to TCP/IP overhead.
There are a couple things you can do
1) You can pre-convert the bitmaps to jpeg images
2) You can send unconverted bitmaps
Otherwise, you should just buy an off-the-shelf package and have done with.
Good Luck!
When it comes to optimization one of the ideas that I see coming up all the time is to make sure you are solving the right problem.
One of the first things that I would do is create a basic logging class that can be used to log how long specific portions of your program take. Right now you are guessing that the TCP/IP overhead and image conversion is what is killing your FPS, but that is just a guess. Your program also has file i/o, which can be slow, and it is executing a bunch of framework code behind the scenes. You may be surprised what is eating your processing time.
All of these are guesses until you do some diagnostics to find out where your time is actually being spent. I wouldn't want to optimize my image conversion code to death only to find out that I had a .Net Framework TCP/IP setting that caused poor performance.
In all my quickness & sillyness I forgot to add Thread.Sleep calls in certain functions for what a Thread has nothing to do....
Now the CPU load has been reduced to 0 :)
Only other problem I have now, is that the sleeping threads mess up my TCP communication, because they don't respond fast enough.
Guess I'll have to change a bit in the protocol and make it more event driven instead of linear messages.
Oralloy 988
Recognized Expert Contributor
I still find it quite difficult to believe that the TCP/IP throughput is affecting your frame rate.
Well, I can imagine how, but you'd have to be using a slow-speed connection like 9600 baud SLIP. Either that, or your network is so loaded that you really are suffering throughput problems, in which case you'd have noticed the problem long before this.
Give your event driven model a try and let us know how it works out.
Cheers!
I've written a new class that handles everything through timers, and i still couldn't get above 10FPS, while theoritcly i should hit 60FPS.
After searching a bit, it seems my applications always needs to wait 100ms to recieve an UDP reply from a third application that tells where the image is located.
So I can never breach the 10FPS barrier as long as the third application doesn't speed up.
Sounds like you'll either need to settle for 10fps or buffer your images.
Probably,
but I'm defo poking the devs of the third application.
Waiting 100ms on loopback for an UDP reply is not acceptable.
Oralloy 988
Recognized Expert Contributor
Can you turn down that 100ms, or is that just the inherent response time of the third application, and something you can't affect?
it's the response time of the application, and would require a serious overhaul I think it make it faster.
It's build on 10year old legacy code and constantly beeing added to;....
So to adjust something in there is like playing with matches in a TNT factory...
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Steve_CA |
last post by:
Hello all,
I've been recruited to assist in diagnosing and fixing a performance problem
on an application we have running on SQL Server 7.
The application itself is third party software, so we can't get at the
source code. It's a Client Management system, where consultants all over
the
country track their client meetings, results, action...
|
by: Amit Dedhia |
last post by:
Hi
I am developing a Dot net application (involving image processing) on
a uni processor. It works well on my machine. I then take all my code
on a multi processor, build and run the application there. There is
performance degradation.
The usual performance of the application on MP machine is better than
that of uni processor machine....
|
by: Girish NS |
last post by:
Hi,
I'm developing a MDI application. I'm facing problems with the performance
of the MDI child forms in the application. The load time of child forms is
very slow. In case of MDI child forms having background image and handling
paint event, the load time is even slower due to the background painting.
Repainting of form controls is also...
|
by: Anders Both |
last post by:
Does someone knows links to web-pages, or book contatining, information
about the most important things to consider, while trying to make the .NET
code perform faster.
e.g. In my code I make big use of ArrayList and Hashtable, but my code would
be only a little bit more complicated, if using normal Arrays. I feel like a
thing like that...
|
by: Dominic |
last post by:
Hi all,
We've just migrated to IIS 6.0 / Windows Server 2003. We are now
experiencing some stability problem what we did not experience in IIS
5.0 / Windows 2000 Server. Our ASP.NET application is running in a
web-farm environment of multiple web servers. We have been using
"Performance Monitor" to monitor the "Requests in Application...
| |
by: groups |
last post by:
Hi all,
I've recently ported a rather large C application to run multithreaded.
A few functions have seriously deteriorated in performance, in
particular when accessing a rather large global array, that contains
information that is shared among threads.
Any idea, why the lines accessing this global array now take about 50x
longer in the...
|
by: Yoav Shtainman |
last post by:
I combined several application projects into one large project for ease of
management and control. My previous application was a collection of small
independent projects. Can this change affect the performance of the
application? It is a .NET Web application using SQL Server back end
|
by: NAdir |
last post by:
Hi, thank you for your help.
My VB.Net application contains a document that the user can refresh at any
time.
The refresh works fine and needs to loop through few datatables (hundreds of
rows). This works fine until I delete some rows in two tables. Just after the
delete if I do the refresh there is a huge memory allocated and the time...
|
by: skotapal |
last post by:
Hello
I manage a web based VB .net application. This application has 3
components:
1. Webapp (this calls the executibles)
2. database
3. business logic is contained in individual exe application that get
called in a sequence to do some heavy calculations (mainly DB
operations with in memory datasets)
|
by: mjheitland |
last post by:
Hello,
does anyone know if an update is available (or at least planned) for
the much cited standard reference
IMPROVING .NET APPLICATION PERFORMANCE AND SCALABILITY?
link:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/scalenet.asp
or as a download:
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
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. ...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |