|
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
|
|
|
|
|
Hi,
I'm writing an MFC application and i need to create an array of char of size [24][512][512]. It compiles grand but when i run the app i get an runtime error about a stack overflow. If i create an array of the same size in a basic C++ app it works fine. Whats the problem with MFC and large arrays, and whats the way around it???
Any help would be appreciated!!
Thanks.
|
|
|
|
|
what about creating the array on the heap using the new operator?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Cheers.
Good idea!! why didn't i think of that! So is there a set limit to how big an array can be declared with the MFC's???
Thanks.
|
|
|
|
|
Unrelated to MFC, the default stack size is 1MB.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi all,
I am currentyl writing a hex editor (yep, as if there are not enough already) but my brain has gone to sleep and for the life of me I can't think of how to do the following...
1. Keeping track of changes for undo/redo functionality, such as inserting / deleting, etc.
any help would be gratefully received.
regards,
jonathan
|
|
|
|
|
At the moment you change something save first in an array or Vector?
preferebly with a fixed number?
Something like that.
if you are working on an hexeditor maybe you should save some other data as well (eg. what kind of file was it) I don't know.
Good luck.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
There was an artical here on code project THIS WEEK that would have told you how.
If you still don't get it after reading that artical, give some indication that you have read it, and all the articals it links. Your right this is a stupid question, but it isn't the question itself, it is your mythod of asking first instead of doing some research first that is stupid.
When you have a question PLEASE start with google. If it is coding related search code project (I have other places in my bookmarks that are sometimes useful, but code project is a good start).
Sorry about the tone, but I feel you deserve it. Do better next time and we will be happy to anser your questions. (If we know)
|
|
|
|
|
Henry,
Chill out! Don't worry about the tone, I deserved it.
But maybe get yourself a spell checker next time
regards,
Darka
|
|
|
|
|
Hi,
I've developed a NT Service using ATL. My service performs some functionality which uses database, XML files and HTTP communication. For database access I am using a COM component which I developed. Though the functionality intended by the service is performed ok, but the service fails to stop after running for sometime. After digging into the problem I found out that the service waiting for returning CoUninitialize() method which is taking too much time. I've ensured that I release all the COM interfaces before reaching CoUninitialize() method.
Can anybody suggest me what could be potential problem.
Thanks
Abhishek.
|
|
|
|
|
Hi,
I am a new in MFC.
I want to call a dialog box on Help button on a propety sheet in MFC.How can I do this? Please help me.
rajesh
|
|
|
|
|
depends on what you would like to do.
If you just want to display a message:
AfxMessageBox("somestring"); will do.
If you would like more options create your new dialog box and do.
yourdialogclassobjectname.DoModal();
DoModal returns an int so you can catch IDOK or IDCANCEL if you like.
Hope this helps.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
In the property sheet, override the OnCommand() method. Then add the following code:
if (BN_CLICKED == HIWORD(wParam) && IDHELP == LOWORD(wParam))
{
return TRUE;
}
return CPropertySheet::OnCommand(wParam, lParam);
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|