thanks I will try this
Renven
Posts
-
Threads, speed up calculations -
Threads, speed up calculationsDaniel Grunwald thanks a lot! results after changing : without threads : 50-70ms with threads: ~115ms significant change, i do not expected to save that much time. :)
-
Threads, speed up calculationsAND, YES most of time is spend in RGBreturnLVL(...) method. //Calculate average 30x30 image color private Color RGBreturnLVL(int PositionX, int PositionY, int width, int height, Bitmap Image) { int ra = 0; int ga = 0; int ba = 0; int total = 0; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { Color clr = CropBitmap(Image, PositionX, PositionY, width, height).GetPixel(x, y); ra += clr.R; ga += clr.G; ba += clr.B; total++; } } ra /= total; ga /= total; ba /= total; return Color.FromArgb(ra, ga, ba); }
-
Threads, speed up calculationsThanks I will look into your comments, change code and then paste
-
Threads, speed up calculations(how code looks after trying with 7 threads (because captured image is divided in 7 rows)) I have to warn you CODE is not optimized. as example I show you only 2 thread methods: ThreadOneP and ThreadTwoP public int TransferToMatrixThread() { temptest = 0; CabX = CabX - 18; CabY = CabY + 53; CabXX = CabX - 484; //POSSITION CabYY = CabY + 20; for (int i = 0; i < 11; i++) //FILLS MATRIX WITH 0 { for (int j = 0; j < 11; j++) { transfered[i, j] = 0; } } ThreadStart ts = new ThreadStart(ThreadOneP); ThreadStart ts2 = new ThreadStart(ThreadTwoP); ThreadStart ts3 = new ThreadStart(ThreadThreeP); ThreadStart ts4 = new ThreadStart(ThreadFourP); ThreadStart ts5 = new ThreadStart(ThreadFiveP); ThreadStart ts6 = new ThreadStart(ThreadSixP); ThreadStart ts7 = new ThreadStart(ThreadSevenP); Thread thread1 = new Thread(ts); Thread thread2 = new Thread(ts2); Thread thread3 = new Thread(ts3); Thread thread4 = new Thread(ts4); Thread thread5 = new Thread(ts5); Thread thread6 = new Thread(ts6); Thread thread7 = new Thread(ts7); DateTime startTime = DateTime.Now; //TIME thread1.Start(); thread2.Start(); thread3.Start(); thread4.Start(); thread5.Start(); thread6.Start(); thread7.Start(); thread1.Join(); thread2.Join(); thread3.Join(); thread4.Join(); thread5.Join(); thread6.Join(); thread7.Join(); DateTime stopTime = DateTime.Now; TimeSpan duration = stopTime - startTime; listBox1.Items.Add("7 THREAD = " + duration); TransfX = currX + CabXX + 9; // norima nustatyti i pav viduri todel pridedamos konstantos TransfY = currY + CabYY + 11; // norima nustatyti i pav viduri todel pridedamos konstantos return temptest; } public void ThreadOneP() { int o = CabYY; int zy = 8; int zx = 2; for (int ok = CabXX; ok < CabXX + 490; ok = ok + 72) { var color22 = RGBreturnLVL(ok, o, 30
-
Threads, speed up calculationsAlso I just now try to set 7 thread 1 thread for each image row. but time consumption is the same as Using 2 threads 900-1000ms. can you tell a little bit mote how to use thread priority, because i thing i i will set high priority for all threads there will be no effect.
-
Threads, speed up calculationsHi, i will be appreciated if someone could help me in this situation: my PC: Pentium 2Core 2.1GHz 4Gb(Ram) windows 7 x64 The problem that I can not solve by myself is how to speed up calculations. My method runs 850-970ms. method created for image processing (crops image ,recognize coped image and put calculated value into matrix) When i am using threads (in this example 2 threads) ThreadStart ts = new ThreadStart(ThreadOneP); ThreadStart ts2 = new ThreadStart(ThreadTwoP); Thread thread1 = new Thread(ts); Thread thread2 = new Thread(ts2); thread1.Start(); thread2.Start(); thread1.Join(); thread2.Join(); method takes 900-1070ms. How to speed up that method will take about 400ms? it is possible? P.S sorry for my English :)
-
how to create 2 threads on on diferent procesorshi guys, I need your help. let's suppose I have Dual-Core CPU and I need know how to create two threads, each in different processor. for example: thread1 runs in 1core thread2 runs in 2core when implementing tread1.start(); thread2.start(); they both run some random function lake NumberTest(); Thanks in advance, renven
-
C# "for example desktop icon"(object) drag and drop methodHi, Lets supose i have C# application witch gets object position in desktop (for example "icon" or "shotcut") coordinates (x,y). I need method whitch uses coordinates from application (x,y, and x_put, y_put) take object from one position and DRAG and DROP that objet to other position. Also it would be great if that methot can WORK FAST. I appretiate your help,