2 Replies Latest reply on Jul 3, 2013 1:12 AM by nikhil.naik

    usb camera use cyusb in xp not loss data but in the win7 loss data in the same pc

    wang.jianhong

      i use the same application to capture the camera data use cyusb.

         

      but now i found that in the system windowx xp it works very well, int win7 32 or vistat system it loss data very strong.

         

      my application code is: the code means capture vide size 1280*720 ,in xp system the return data alomost is 1280*720,

         

      but in win7 32 or vista system it is alomost less 1280*720. i check the driver in win7 and vista is right.

         

      by the way the xp system and win7 system vista is install in the same pc.

         

      can any people help me?  thanks.

         

      DWORD WINAPI Camera_Thread(void *param)
      {

          CCyUSBEndPoint*     pInEndpt    = pUSB->BulkInEndPt;
          int QueueSize  = 2;
          PUCHAR            *inContext        = new PUCHAR[QueueSize];
          OVERLAPPED        *inOvLap = new OVERLAPPED[QueueSize];
          PUCHAR            *buffers        = new PUCHAR[QueueSize];
          for (int i=0; i< QueueSize; i++)
          {    
              inOvLap[i].hEvent = CreateEvent(NULL, false, false, NULL);
          }
          pInEndpt->TimeOut = 1000;
          pInEndpt->SetXferSize(1024*1024);

          for(int i=0;i<QueueSize;i++)
              buffers[i] = new unsigned char [1024*1024];

          for(int i=0;i<QueueSize;i++)
              inContext[i] = pInEndpt->BeginDataXfer(buffers[i], 1024*1024, &inOvLap[i]);
          LONG  dwBytes     = 0;
          int i=0;
          while(m_bPlaying)
          {
              pInEndpt->WaitForXfer(&inOvLap[i], 1000);

              pInEndpt->FinishDataXfer(buffers[i], dwBytes, &inOvLap[i], inContext[i]);

              inContext[i] = pInEndpt->BeginDataXfer(buffers[i],1024*1024,&inOvLap[i]);
              if(dwBytes==1280*720)
              {
                  pCameraFrameCount++;
              }

              i++;
              if(i==QueueSize)
              {
                  i=0;
              }
          }
             
          return 0;
      }