|
I used DEBUG configuration
With RELEASE conf, it's better.
Thanks
Tonight, ciao Greece ...
|
|
|
|
|
Two rules of performance measuring:
1. Never mesure DEBUG code.
2. Never mesure dumb code (it will be optimized out).
I've modified your test and came out with the following results:
Inline :24437 ms
Macro :24531 ms
Function:40594 ms
In place:24391 ms
As you see, function calls add a little overhead, all other cases are practically identical (as they should be).
Also, if you'd look at generated code, you'd see that "inline" works just fine - there is no "call", it inserts "imul" instruction.
-----------------------------
Get trial copy of comment generating tool CommentMakerPro, std::string and std::string containers viewer FeinEvaluatorPro and windows manager for Microsoft Visual Studio .NET FeinWindows at www.FeinSoftware.com
|
|
|
|
|
Right, optimizations are off by default in DEBUG mode.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Here i found a problem in my project, We're a TCP communication peers, the remote peer needs the RST flag to reset it internal buffers, when one transaction is completed between us. but now i solved the problem by closing the socket and opening the socket again and start a new transaction, because while closing the connection the client will send an RST flag, to the peer clearing the buffers at the peer side, but i need to send the RST flag by setting the RST flag in the TCP header but without closing the socket connection.
thanks in advance for the solution given by message board members, plz it's very urgent.
s.s.s.eswaran
|
|
|
|
|
Hi,
Does anybody knows how to prevent Visual C++ 6 to crash when
linking variables to Dialogs in Classwizard on Windows XP Pro?
Symptoms: the "Main_Dlg.cpp" file cannot be updated and disapears.
(I know the trick with the .tmp file, but I want to know if there is a
patch from Microsoft)
Thank you
Kassad
|
|
|
|
|
Which service pack are you using? Right now visual studio is at service pack 6. I would not recommend using visual studio without at least sp4 installed. Most of the GUI problems with the initial version of vc6 are fixed but there are still bugs with the class view in sp6. If you reorganize your code in the classview by using folders, vc6 can and will forget this whenever it wants... Good thing there are some tools here that allow you to back this up for each project. I find myself restoring a backup of this info at least once a day...
John
|
|
|
|
|
Hi,
I was using the SP5 and I'm downloading the SP6
I'm interrested by the "tools" for "backuping".
Thank you.
B->
Kassad
|
|
|
|
|
I use CDialogBars in my SDI app and I need to manage the availability of some buttons I've placed over that.
So I've written this code i CMainFrame:
MyDialogBar.GetDlgItem(MY_BUTTON).EnableWindow(FALSE);
but it doesn't work ! buttons availability doesn't change !
Can someone help me ?
|
|
|
|
|
Hi,
I've got a major problem in my little program. I use a self made class which contains an integer array. In the classes constructor I initialite this array with the following statement:
ar = new int[number];
where "ar" is a int* and "number" is a passed parameter.
In debug configuration everything works fine but in release config the program crashes at this line when "number" is greater than 4.
I can't find an explanation or solution. Can anybody help, please?
|
|
|
|
|
Something else is at play here as I "see" nothing wrong with what you've described so far. I put the following together:
class dc
{
int *ar;
public:
dc(const int n)
{
ar = new int[n];
}
~dc()
{
delete [] ar;
}
};
void main( void )
{
dc d(760);
} It works fine. How does yours differ?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
That's exactly what I did. With debug configuration settings it forks fine with all array sizes I apply but when I change to release config settings the program terminates without any message when I apply parameters greater than 4. Strange isn't it?
I use:
Win XP Home
Visual C++ 6 Author Edition
Allegro
|
|
|
|
|
|
Sir,
Really codeproject projects are very easy to understand. When I search in any search engine, first i will go for codeproject link from serach results. Thanks for your help.
I coded a dll using ATL,WTL to add toolbar in Internet Explorer. Now i have to redirect one particular page when navigate fails. For that i want to implement DWebBrowserEvents.
My dll will activate when Internet Explorer will run. Dll is not creating any instance of internet explorer.
please reply me.
Acharya Arti
Acharya Arti
|
|
|
|
|
I have a template class:
template<class T>
class Bag {
...
}
The member functions are defined inline in the header file. The following member functions are examples of what is causing a problem:
template<class T>
inline Bag<T>::Node* Bag<T>::alloc_node()
{
...
}
template<class T>
inline void Bag<T>::free_node(Bag<T>::Node* node)
{
...
}
The code compiles with no problems in Visual C++ 2002, but in Visual C++ 2003 I get tons of errors.
For the first example above, I get:
error C2065: ‘T’: undeclared identifier
For the second example, I get:
error C2065: ‘node’: undeclared identifier
Any ideas? I do know that VS.NET 2003 is much more standards compliant than VS.NET 2002, perhaps this code is non-standard somehow? If so, how can I fix it?
(I had to turn off HTML formatting in this post so that the template code would show up properly. Is there a way to escape angle brackets?)
|
|
|
|
|
I found the solution. There is a new standard. You must include "typename" in front of all the return types and parameter types that cause an error.
|
|
|
|
|
Hi,
I've to develop a real-time capable image processing software. My data stream is 720 x 576 in RGB and my aim is to process 30 frames per second (as data is stored in tiff one single image is about 1.6MB).
Unfortunately I had to discover that a even very simple operations (like multiplication, division, ...) on every colour byte (that is 720 x 576 x 3) demand about 30ms. I'm quite surprised as I thought this very basic operations are performed much faster. I'm compiling on a 1,2 GH Pentium M with 512MB Ram and compiler setting are on "release" (.NET 2003, using c++).
I tried to speed things up and discovered that for example the following code needs about 40ms
loop throug all pixels
current_pixel = ( current_pixel * some_value ) / ( some_int_value)
If I changed "some_int_value" to a const value the whole loop executes in 15ms. But I need this value as an variable as it changes for each new frame I process, but in the loop the value doesnt change. Thus I wonder if there is some way to make use of this fact. Maybe some experts have some tips for me? (By the way, even 15ms exec time for these operations make me wonder, some comments on that? Shouldnt it be much faster?).
Another issue is: what is the best/appropriate method for loading a new frame each 30 ms. Simply loading the new file with GDI++ (using Image constructor) every new 30ms works for the first few frames but then fails (too slow). Do I need some kind of buffer solution? Any advice how to start, how to do this? Thanks
If you need more detailed information about the code I use please let me know.
I'm grateful for any advice that might help me.
Thank you very much
Michael
(a c++ novice)
Appendix:
My compiler settings for the project on release settings:
/O2 /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D "_AFXDLL" /D "_MBCS" /FD /EHsc /MD /GS /Zc:wchar_t /Yu"stdafx.h" /Fp"Release/GazeMFC.pch" /Fo"Release/" /Fd"Release/vc70.pdb" /W3 /nologo /c /Wp64 /Zi /Gd /TP
|
|
|
|
|
Multiplication is faster than division. I don't know by how much though... But you could try something like this:
val = 1.0 / some_int_value;<br />
for each pixel<br />
{<br />
current_pixel *= some_value * val;<br />
}
Then you only have one division per loop.
Of course, if the some_value also does not change during the loop, then do this:
val = some_value / some_int_value;<br />
for each pixel<br />
{<br />
current_pixel *= val;<br />
}
So then you have cut your number of operations in half.
This may or may not have a noticeable effect on execeution time, but it is definitely more efficient code.
|
|
|
|
|
Hi,
redmop wrote:
even 15ms exec time for these operations make me wonder, some comments on that? Shouldnt it be much faster?
I don't know much about image processing but I looked at your question and it made me think about the number of operations you are doing.
If your image is (720 * 576 * 3)bytes then you have 1244160 bytes to work on, which is a lot! If it takes a total of 30ms, then each byte is taking 24ns (ie 30ms / 1244160). And if you consider that a 1.2G processor has a clock cycle every 833pico seconds, then you have 28 cycles per operation which doesn't sound totally unreasonable to me for a multiplication and division.
Also, the fact that you changed one value to a const and it dramically changed the time for execution indicates that it is spending alot of time retreiving data.
I'm sorry that I can't offer you much advice about how to speed it up, but if it were my code I would try to discover which part of the loop takes the longest and contentrate on speeding that up. It sounds obvious I know, but I have spent hours optimising one bit of code only to find another bit takes 10 times as long!
Cheers & Good Luck,
Ali
|
|
|
|
|
The other posters have reasonable suggestions.
Post your looping code. I have seen many cases where computing array indeces involves fairly complex expressions that are computed for every byte of the pixel which can be very slow. Using temporary variables for expressions that calculated repeatedly can be sometimes provide a noticeable improvement.
__________________________________________
a two cent stamp short of going postal.
|
|
|
|
|
If you can put together a little framework that loads one of your images and calls the processing function (that took 30ms), we could make a little competition for the fastest code.
Everyone will have fun, and you'll get really fast function.
-----------------------------
Get trial copy of comment generating tool CommentMakerPro, std::string and std::string containers viewer FeinEvaluatorPro and windows manager for Microsoft Visual Studio .NET FeinWindows at www.FeinSoftware.com
|
|
|
|
|
Real-time image processing is really processor intensive. As someone mentioned, your timings aren't so unreasonable when you consider what you're actually trying to do (although I agree that you should be able to improve on 30ms). Anyhow, here are a few tips:
Reduce the amount of data you need to process
=============================================
1. Do you really need to work with 24 bit images. If you can get away with 16 bit or, better still, 8 bit then you'll reduce your timings by 33% or 66%.
2. Do you really need to use such large images - reducing image size to 640 x 480, for example, would reduce timings by 25%
3. Do you really need to process 30 frames per second. 24 frames per second is almost indistinguishable from 30 and again speeds things up.
So, for example, using 640x480, 16 bit images at 24 fps would reduce the amount of processing by about 60%.
You may find that your code is 'data bound'. This means that the processor is actually spending more time getting data than processing - remember the CPU might run at 1.2GHz but the memory doesn't. I know you've got cache but your images are 1.6MB.
Coding
======
1. If possible use MMX instructions. These process 8 bytes or 4 words in parallel - they offer dramatic improvements over processing images a pixel at a time.
2. As mentioned by someone else, optimise your loops - process as much as you can outside the loop.
3. Check out the Intel optimisation manuals - they're a free download from intel's site. They contains lots of tips on optimising your code.
By the way, what are you actually trying to achieve by multiplying your pixels by one value and then dividing them by some other value?
If you want some specific advice then send me some details of the project.
Good luck
Chris.
PS: If you've got come money to spend then the Intel Performance Primitives library ($199.00) contains great image processing routines covering most needs.
|
|
|
|
|
Hi again,
first of all I want to say I'm very thankful to all of you for your tips, opinions and suggestions, especially the comment from A. Pentland was very plausible for me.
Instead of answering each of you I'll do it all together here.
1) Amount of data that is proccessed and what exactly is he doing?
Yes I could reduce the amount of data but I wanted to simulate the "worst case" first, and that means this high resolution and using all colour channels and 30frames per sec
(I'm quite sure that I wont reach that aim . I'm particulary interested in the face and eye region for gaze estimation, therefore I need high resolution images to achieve
some accuracy. A very basic thing is to blur the input image first (to get rid of noise). Using a 3x3 filter I would need 12 additions and one divions for each colour channel.
Ok in this case the divisor can be a const value but for other things like normalizing the intensity I would use lets say the average intensity of the whole image. And these
are just basic things, of course I need more complicated methods to detect the face/eyes/iris/pupil etc.
2) Looping code:
--------------------------snip--------------------------------------------------------------------------------------------
// m_pVectorIn is the pointer to the bitmap data
// m_pVectorOut is the pointer to data of a different bitmap
//m_nWidth = 3 * m_iWidth // and m_iWidth is the image width
unsigned char* pSource = m_pVectorIn + m_nWidth;
unsigned char* pDrain = m_pVectorOut + m_nWidth;
for(int y=1;y
|
|
|
|
|
redmop wrote:
first of all I want to say I'm very thankful to all of you for your tips, opinions and suggestions, especially the comment from A. Pentland was very plausible for me.
Cheers, its nice to be appreciated.
Unfortunately I don't think I can offer much more advice, but your project sounds really interesting, good luck!
Ali
|
|
|
|
|
hello,
if u can help me I am having some doubt int reading a bmp image in vc++. I am also doing some image processing programming in vc++, in which I have to read the image at first, but I am not getting how to read an image in vc++ though I can do it easily in Matlab.
thanks in advance,
Pavan.
|
|
|
|
|
Hi All
i get the below error when connecting to an access database
[Microsoft][ODBC Microsoft Access Driver] Couldn't use '(unknown)'; file already in use.
i use
hr = cpDbCMIS->Open("DSN=CP_CMIS_CON;UID=;PWD=","","",-1);
to connect to it.
The first time my application is run, the app asks the user for the location of an
access db, once it has been located i create an ODBC connection to it,
my app then trys to connect to it, using
hr = cpDbCMIS->Open("DSN=CP_CMIS_CON;UID=;PWD=","","",-1);
which is when i get the error
The second time and all other times when my app is run, (there is no need to create
an ODBC connection again as it was already created the first time my app was run.)
then my app it connects to the database sucessfully and i get no problems
using
hr = cpDbCMIS->Open("DSN=CP_CMIS_CON;UID=;PWD=","","",-1);
but the above error appears after the first time its run
has ne1 any ideas ?????
hope this makes sense
Si
|
|
|
|