2

検出された面を平行に抽出することでViola-Jonesを高速化したいが、このコードを使用するが、For Each文の中でface引数に誤りがある。このエラーはどうですか? エラーが方法System.Threading.Tasks.Parallel.ForEach<TSource>(System.Collections.Concurrent.OrderablePartitioner<TSource>, System.Action<TSource,System.Threading.Tasks.ParallelLoopState,long>)の型引数は使用状況から推測することはできませんパラレルForEachをViola-Jonesに書き込む方法

(エラー2で明示的に型引数を指定してみてください
D:\ Hadeel \ 00論文\顔認識の\ C#の\のバックアップ\ヴィオラとジョーンズ
2結果 - コピー\ヴィオラとジョーンズは、ヴィオラとジョーンズが2結果356 25
2 \ Form1.csの結果)

else if (chcParallel.Checked == true) 
{//Rectangle face=new Rectangle(); 
    Parallel.ForEach( face, faceObjects => 
    { 
     graphicRect.DrawRectangle(p, face); 
     face.Inflate(-10, -10);// resize face for crop face without background 

     Crop crop = new Crop(face); 

     Bitmap newimage = crop.Apply(image); 

     // ResizeBicubic resixe = new ResizeBicubic(460, 480); 
     //newimage = resixe.Apply(newimage); 
     //pictureBox2.Image = (newimage); 
     if (chcSkin.Checked == false) 
     { 
      facearray[i] = newimage; 
      pictureBox2.Image = facearray[i]; 
      i = i + 1; 
     } 
     else if (chcSkin.Checked == true) 
     { 
      f1 = 0; f2 = 0; f3 = 0; 
      Bitmap imagess = new Bitmap(newimage); 
      for (int x = 0; x < imagess.Width - 1; x++) 
      { 
       for (int y = 0; y < imagess.Height - 1; y++) 
       { 
        Color pixelColor = imagess.GetPixel(x, y); 
        int r = pixelColor.R; 
        int g = pixelColor.G; 
        int b = pixelColor.B; 
        //  int f1 = 0; 
        //  int f2 = 0; 
        //  int f3 = 0; 
        int differenceMinMax = Math.Max(r, Math.Max(g, b)) - Math.Min(r, Math.Min(g, b)); 

        if (r > 95 & g > 40 & b > 20 & differenceMinMax > 15 & r > g & r > b) 
        { 
         f1 = f1 + 1;// image.SetPixel(x, y, Color.White); 
        } 
        else if (r > 220 & g > 210 & b > 170) 
        { 
         f2 = f2 + 1;// imagess.SetPixel(x, y, Color.White); 
        } 
        else 
        { 
         f3 = f3 + 1;// imagess.SetPixel(x, y, Color.White); 
        } 
       } 
      } 
      if ((f1 > f2) && (f1 > f3)) 
      { 
       facearray[i] = newimage; 
       pictureBox2.Image = facearray[i]; 
       i = i + 1; 
      } 
     } 
     //else 
     //{ } 
    }); 

    graphicRect.Dispose(); 
    pictureBox1.Image = image; 
}//end if Parallel True 
+0

どのようなタイプが 'face'と' faceObjects'ですか? – meJustAndrew

答えて

0

それはのために伝えるのは難しいです確かに、faceオブジェクトをラムダパラメータとしてマークしようとしていますか?次に、パラメータを切り替える必要があります:

// for each of faceObject do 
Parallel.ForEach(faceObjects, face => 
{ 
    // your code here 
}); 
+0

ありがとう、はい私はそれをしましたが、それは仕事ではない、私は思っていたように並列は不可能です。 –

+0

@HiraqiHmaster 'not work'とはどういう意味ですか? – VMAtm

+0

私は、ビオラ・ジョーンズのコードでは並列処理を行うことができませんでした。リアルタイムの顔検出のために速くしたいのですが、できません。 –

関連する問題