473,386 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Image processing

hi all there.

im new in BYTES, this is my first post.
i m working on a project regarding image processing. i m working on face detection from video. i hv played the video captured from webcam on a picture box.I hv splitted it into frames it plays like original(means no problem) but as i attach or call some algorithm with it bofore display it becomes slower and plays like slow motion. What could b the problem.

thanks in advance.
hony,
Jul 1 '10 #1

✓ answered by code green

There may be howls of derision but I would improve this
Expand|Select|Wrap|Line Numbers
  1. for (Int32 x = 0; x < original.Width; x++) 
By storing Width in a variable to avoid multiple class calls
Expand|Select|Wrap|Line Numbers
  1. w = original.Width;
  2. for (Int32 x = 0; x < w; x++) 
Same for height.

5 1322
code green
1,726 Expert 1GB
I would say your algorithm code is slowing it down.
It may be worth seeing if it can be optimised, otherwise multi-threading may be the answer
Jul 1 '10 #2
That could be a problem, but i dont think that the algorithm is such a complex anyhow, here is the algorithm which applies on each frame of video.


Expand|Select|Wrap|Line Numbers
  1. static ArrayList points = new ArrayList();
  2.         static Int32 xx = 0, yy = 0;
  3.         static int clrdpix;
  4.         static int rect_width = clrdpix;
  5.         static int clr_line_count = 0;
  6.  
  7.         public static Bitmap DetectSkin(Bitmap original, Bitmap modified)
  8.         {
  9.             Graphics g = Graphics.FromImage(original);
  10.             clr_line_count = 0;     //Skin Colored Lines Count
  11.             int strtpix = 0;        //Pixel from where rectangle begain to draw.
  12.  
  13.             for (Int32 y = 0; y < original.Height; y++)
  14.             {
  15.                 clrdpix = 0;
  16.  
  17.                 for (Int32 x = 0; x < original.Width; x++)
  18.                 {
  19.                     Color c = modified.GetPixel(x, y);
  20.  
  21.                     double I = (Math.Log(c.R) + Math.Log(c.B) + Math.Log(c.G)) / 3;
  22.                     double Rg = Math.Log(c.R) - Math.Log(c.G);
  23.                     double By = Math.Log(c.B) - (Math.Log(c.G) + Math.Log(c.R)) / 2;
  24.                     double hue = Math.Atan2(Rg, By) * (180 / Math.PI);
  25.  
  26.                     if (I <= 6 && (hue >= 100 && hue <= 255))
  27.                     {
  28.                         clrdpix++;
  29.  
  30.                         if (clr_line_count == 50 && clrdpix == 1)
  31.                         {
  32.                             strtpix = x;
  33.                         }              
  34.                      }
  35.  
  36.                     else
  37.                     {
  38.                         //modified.SetPixel(x, y, Color.Black);
  39.                     }
  40.  
  41.  
  42.                 }
  43.                 if (clr_line_count == 50)
  44.                 {
  45.                     xx = strtpix;
  46.                     yy = y;
  47.                     rect_width = original.Width - (original.Width - clrdpix) - 20;
  48.                     //Console.WriteLine("Colored Pixel Value =" + clrdpix);
  49.                     //Console.WriteLine("xx Value =" + strtpix);
  50.                     //Console.WriteLine("yy Value =" + yy);
  51.                 }
  52.                 if(clrdpix>0)
  53.                 clr_line_count++;
  54.             }
  55.  
  56.             return modified;
  57.         }
Jul 1 '10 #3
code green
1,726 Expert 1GB
There may be howls of derision but I would improve this
Expand|Select|Wrap|Line Numbers
  1. for (Int32 x = 0; x < original.Width; x++) 
By storing Width in a variable to avoid multiple class calls
Expand|Select|Wrap|Line Numbers
  1. w = original.Width;
  2. for (Int32 x = 0; x < w; x++) 
Same for height.
Jul 1 '10 #4
Thanks alot dear;
i got u.
but i m waiting for ur reply with more mistakes u caught from this code.

thanks again
Jul 2 '10 #5
code green
1,726 Expert 1GB
If somebody on this forum suggested code optimization to me,
I would eagerley rush off and study the subject.
I would not lie back and expect an expert to optimise the code for me
Jul 2 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Alexandre Fayolle | last post by:
Hello, I'm about to start a project which will involve some greyscale image processing using morphological operators (erosion, dilation, distance transforms...), and I was wondering if these...
0
by: Andreas Håkansson | last post by:
Hiya! I'm currently looking for a good image processig component (classes) to use in a project. I do not want to controls (winform or webform) since I will be doing this with code. I actually...
2
by: Maxwell2006 | last post by:
Hi, I am developing a simple image upload asp.net page and I am looking for a simple image processing component to be able to change the image resolution of jpg images and also reduce the...
10
by: stonny | last post by:
Hi, I am converting my matlab program into C/C++. I need to change some image processing toolbox functions into C/C++, such as edge detection, mathematical morphology. Is there any place that I...
1
by: stonny | last post by:
Hi, I am converting my matlab program into C. I need to change some image processing toolbox functions into C, such as edge detection, mathematical morphology. Since I am not very comfortable with...
5
by: edurand | last post by:
Hi, We are are pleased to announce the version 3.0 of the image processing library 'Filters'. You can use it in Python, and we have provided tutorials and samples in Python, with for exemple...
3
by: birensubudhi | last post by:
hey guys,can anyone tell me what is image processing, how to do it using C. IN KSHITIJ 2007 held at IIT kgp a que by INFOSYS is asked, they hav given an image then cut in different orientation...
26
by: mohangupta13 | last post by:
can anyone help me where to find the best image processing library for c++ mohan gupta
5
by: whisk3rs | last post by:
Hello, I have a conceptual question. I need to write a program that will take as input a list of images and then process each image individually (extract useful features from the image) ...
0
by: tavares | last post by:
(Our apologies for cross-posting. We appreciate if you kindly distribute this information by your co- workers and colleagues.) ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.