title: Using OpenCL and GPU is not increasing fps performance of my Camera
body: <p>I compiled this simple color tracking  Image Processing program using OpenCV and Visual Studio 2012.
  First I compiled it using CPU.
  Program:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "opencv2/highgui/highgui.hpp"
  #include "opencv2/imgproc/imgproc.hpp"
  #include &lt;time.h&gt;
  
  using namespace cv;
  using namespace std;
  
   int main( int argc, char** argv )
   {
      time_t t= time(0);
      VideoCapture cap(0); //capture the video from web cam
  
      if ( !cap.isOpened() )  // if not success, exit program
      {
           cout &lt;&lt; "Cannot open the web cam" &lt;&lt; endl;
           return -1;
      }
       double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
     double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video
  
      cout &lt;&lt; "Frame size : " &lt;&lt; dWidth &lt;&lt; " x " &lt;&lt; dHeight &lt;&lt; endl;
  
      namedWindow("Control", CV_WINDOW_AUTOSIZE); //create a window called "Control"
  
    int iLowH = 0;
   int iHighH = 179;
  
    int iLowS = 0; 
   int iHighS = 255;
  
    int iLowV = 0;
   int iHighV = 255;
  
    //Create track bars in "Control" window
   cvCreateTrackbar("LowH", "Control", &amp;iLowH, 179); //Hue (0 - 179)
   cvCreateTrackbar("HighH", "Control", &amp;iHighH, 179);
  
    cvCreateTrackbar("LowS", "Control", &amp;iLowS, 255); //Saturation (0 - 255)
   cvCreateTrackbar("HighS", "Control", &amp;iHighS, 255);
  
    cvCreateTrackbar("LowV", "Control", &amp;iLowV, 255); //Value (0 - 255)
   cvCreateTrackbar("HighV", "Control", &amp;iHighV, 255);
  
      int fps=0;
      int cur=0;
      while (true)
      {
      fps++;
          t=time(0);
          struct tm *tmp = gmtime(&amp;t);
  
          int h= (t/360) %24;
          int m= (t/60) %60;
          int s = t%60;
          if(cur !=s)
          {
              cout&lt;&lt;fps&lt;&lt;endl;
              fps=0;
              cur=s;
          }
          Mat imgOriginal;
  
          bool bSuccess = cap.read(imgOriginal); // read a new frame from video
  
           if (!bSuccess) //if not success, break loop
          {
               cout &lt;&lt; "Cannot read a frame from video stream" &lt;&lt; endl;
               break;
          }
  
      Mat imgHSV;
  
     cvtColor(imgOriginal, imgHSV, COLOR_BGR2HSV); //Convert the captured frame from BGR to HSV
  
    Mat imgThresholded;
  
     inRange(imgHSV, Scalar(iLowH, iLowS, iLowV), Scalar(iHighH, iHighS, iHighV), imgThresholded); //Threshold the image
  
    //morphological opening (remove small objects from the foreground)
    erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) );
    dilate( imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) ); 
  
     //morphological closing (fill small holes in the foreground)
    dilate( imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) ); 
    erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) );
  
     imshow("Thresholded Image", imgThresholded); //show the thresholded image
    imshow("Original", imgOriginal); //show the original image
  
          if (waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
         {
              cout &lt;&lt; "esc key is pressed by user" &lt;&lt; endl;
              break; 
         }
      }
  
     return 0;
  
  }
  </code></pre>
  
  <p>My Camera was giving an fps of 16.
  Then I compiled this program using OpenCL (GPU  Support).
   Program:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "opencv2/highgui/highgui.hpp"
  #include "opencv2/imgproc/imgproc.hpp"
  #include &lt;opencv2/ocl/ocl.hpp&gt;
  #include &lt;time.h&gt;
  
  using namespace cv;
  using namespace std;
  
   int main( int argc, char** argv )
   {
      time_t t= time(0);
      VideoCapture cap(0); //capture the video from web cam
  
      if ( !cap.isOpened() )  // if not success, exit program
      {
           cout &lt;&lt; "Cannot open the web cam" &lt;&lt; endl;
           return -1;
      }
       double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
     double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video
  
      cout &lt;&lt; "Frame size : " &lt;&lt; dWidth &lt;&lt; " x " &lt;&lt; dHeight &lt;&lt; endl;
  
      namedWindow("Control", CV_WINDOW_AUTOSIZE); //create a window called "Control"
  
    int iLowH = 0;
   int iHighH = 179;
  
    int iLowS = 0; 
   int iHighS = 255;
  
    int iLowV = 0;
   int iHighV = 255;
  
    //Create track bars in "Control" window
   cvCreateTrackbar("LowH", "Control", &amp;iLowH, 179); //Hue (0 - 179)
   cvCreateTrackbar("HighH", "Control", &amp;iHighH, 179);
  
    cvCreateTrackbar("LowS", "Control", &amp;iLowS, 255); //Saturation (0 - 255)
   cvCreateTrackbar("HighS", "Control", &amp;iHighS, 255);
  
    cvCreateTrackbar("LowV", "Control", &amp;iLowV, 255); //Value (0 - 255)
   cvCreateTrackbar("HighV", "Control", &amp;iHighV, 255);
  
      int fps=0;
      int cur=0;
      while (true)
      {
      fps++;
          t=time(0);
          struct tm *tmp = gmtime(&amp;t);
  
          int h= (t/360) %24;
          int m= (t/60) %60;
          int s = t%60;
          if(cur !=s)
          {
              cout&lt;&lt;fps&lt;&lt;endl;
              fps=0;
              cur=s;
          }
          Mat imgOriginal;
  
          bool bSuccess = cap.read(imgOriginal); // read a new frame from video
  
           if (!bSuccess) //if not success, break loop
          {
               cout &lt;&lt; "Cannot read a frame from video stream" &lt;&lt; endl;
               break;
          }
  
      Mat imgHSV;
  
     cvtColor(imgOriginal, imgHSV, COLOR_BGR2HSV); //Convert the captured frame from BGR to HSV
  
    Mat imgThresholded;
  
     inRange(imgHSV, Scalar(iLowH, iLowS, iLowV), Scalar(iHighH, iHighS, iHighV), imgThresholded); //Threshold the image
  
    //morphological opening (remove small objects from the foreground)
      ocl::oclMat alpha(imgThresholded);
      ocl::erode(alpha,alpha, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) );
      ocl::dilate( alpha, alpha, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) ); 
  
     //morphological closing (fill small holes in the foreground)
      ocl::dilate( alpha, alpha, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) ); 
      ocl::erode(alpha, alpha, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) );
      imgThresholded = Mat(alpha);
     imshow("Thresholded Image", imgThresholded); //show the thresholded image
    imshow("Original", imgOriginal); //show the original image
  
          if (waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
         {
              cout &lt;&lt; "esc key is pressed by user" &lt;&lt; endl;
              break; 
         }
      }
  
     return 0;
  
  }
  </code></pre>
  
  <p>But now i am getting a fps = 10 . Please can someone tell Why is this Happening.
  I read somewhere that GPU Support improves the fps performance. Graphic Card I am Using Is AMD RAEDON . </p>