Example #1
0
/**
 * \brief  Return the next good location (which may be the current location),
 *         and advance grid progress one position beyond that. If no good
 *         locations remain then return DmtxRangeEnd.
 * \param  grid
 * \return void
 */
static int
PopGridLocation(DmtxScanGrid *grid, DmtxPixelLoc *locPtr)
{
   int locStatus;

   do {
      locStatus = GetGridCoordinates(grid, locPtr);

      /* Always leave grid pointing at next available location */
      grid->pixelCount++;

   } while(locStatus == DmtxRangeBad);

   return locStatus;
}
Example #2
0
/**
 * @brief  Find next barcode region
 * @param  dec Pointer to DmtxDecode information struct
 * @param  timeout Pointer to timeout time (NULL if none)
 * @return Detected region (if found)
 */
extern DmtxRegion
dmtxDecodeFindNextRegion(DmtxDecode *dec, DmtxTime *timeout)
{
   DmtxScanGrid *grid;
   DmtxPixelLoc loc;
   DmtxRegion   reg;

   grid = &(dec->grid);

   /* Continue scanning until we run out of image or run out of time */
   for(;;) {

      /* Check if grid has been completely traversed */
      if(grid->extent < grid->minExtent) {
         reg.found = DMTX_REGION_EOF;
         break;
      }

      /* Pick up where previous scan left off */
      loc = GetGridCoordinates(grid);

      /* Increment grid away from this location to prevent repeat visits */
      IncrementPixelProgress(grid);

      /* Scan this pixel for presence of a valid barcode edge */
      reg = dmtxScanPixel(dec, loc);

      /* Found a barcode region */
      if(reg.found == DMTX_REGION_FOUND)
         break;

      /* Ran out of time */
      if(timeout != NULL && dmtxTimeExceeded(*timeout)) {
         reg.found = DMTX_REGION_TIMEOUT;
         break;
      }
   }

   return reg;
}