|
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
|
|
|
|
|
"In the MFC application the dialog is initialised or called using Create function like this
dlg->Create(IDD_DIALOG, this);
This will call the OnInitDialog() function automatically, when the application is configured in Debug mode, but it is not called when it is in Release mode. Can anybody tell me what could be the reason?"
thanks
vidya
|
|
|
|
|
How are you verifying that the OnInitDialog() method is not being called?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
In debug mode i can confirm this using break point but in release mode i put one messagebox inside the oninitdialog fucntion which didnt not called in release mode.....and in that function only i am showing the controls in dialog like this....
e.g m_Combo.ShowWindow(SW_SHOW);
since oninitdialog is not called my controls in the dialog are displayed.
vidya
|
|
|
|
|
By chance are there any ActiveX controls on the dialog? What happens if you use a modal, instead of a modeless, dialog?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Yes ....there is an Active-X control in that dialog...
here i am explaining in detail.....
This dialog is added as a property page into the propertysheet. This dialog contains 2 static texts, 2 combo boxes and one MSChart Active-X control.
and in release mode all are not displayed where they are shown in
OnInitDialog() function which has been not called.
Thanks
vidya
|
|
|
|
|
Just for grins, remove the ActiveX control from the dialog template and see if that makes a difference. If it does, it sounds like the ActiveX control is not properly registered, or a call to AfxEnableControlContainer() has not been made (correctly).
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I have deleted the mschart active x control and tested still the other controls like combo boxes are not displayed. The active x control has been registered in windows registry using the following command
regsvr32 C:\winnt\system32\mschrt20.ocx
and the function AfxEnableControlContainer() is also called in InitInstance() function and the required header file #include <afxdisp.h> is also included in the stdafx.h file.
Still the problem exists. Please help me to solve this problem as soon as possible. we have a release by this week end.
thanks
vidya
|
|
|
|