Modules-old/ImageProcRobocup/lua_ImageProc.cpp
//Downsample camera YUYV image for monitor
Downsample camera YUYV image for monitor
Downsample camera YUYV image for monitor
static int lua_subsample_yuyv2yuyv(lua_State *L){
  static std::vector<uint32_t> yuyv_array;
  uint32_t *yuyv = (uint32_t *) lua_touserdata(L, 1);
  if ((yuyv == NULL) || !lua_islightuserdata(L, 1)) {
    return luaL_error(L, "Input YUYV not light user data");
  }
  int m = luaL_checkint(L, 2);
  int n = luaL_checkint(L, 3);
  int subsample_rate = luaL_checkint(L, 4);
  yuyv_array.resize( m*n/subsample_rate/subsample_rate );
  int yuyv_ind = 0;
  for (int j = 0; j < n; j++){
    for (int i = 0; i < m; i++) {
      if (((i%subsample_rate==0) && (j%subsample_rate==0)) || subsample_rate==1)	{
        yuyv_array[yuyv_ind++] = *yuyv;
      }
      yuyv++;
    }
  }
  lua_pushlightuserdata(L, &yuyv_array[0]);
  return 1;
}
static int lua_subsample_yuyv2yuyv ( lua_State * L ) { static std :: vector < uint32_t > yuyv_array ; uint32_t * yuyv = ( uint32_t * ) lua_touserdata ( L , 1 ) ; if ( ( yuyv == NULL ) || ! lua_islightuserdata ( L , 1 ) ) { return luaL_error ( L , " " ) ; } int m = luaL_checkint ( L , 2 ) ; int n = luaL_checkint ( L , 3 ) ; int subsample_rate = luaL_checkint ( L , 4 ) ; yuyv_array . resize ( m * n / subsample_rate / subsample_rate ) ; int yuyv_ind = 0 ; for ( int j = 0 ; j < n ; j ++ ) { for ( int i = 0 ; i < m ; i ++ ) { if ( ( ( i % subsample_rate == 0 ) && ( j % subsample_rate == 0 ) ) || subsample_rate == 1 ) { yuyv_array [ yuyv_ind ++ ] = * yuyv ; } yuyv ++ ; } } lua_pushlightuserdata ( L , & yuyv_array [ 0 ] ) ; return 1 ; }
Downsample camera YUYV image for monitor
Downsample camera YUYV image for monitor
// 1st Input: Original YUYV-format input image // 2nd Input: Width (in YUYV macropixels) of the original YUYV image // 3rd Input: Height (in YUVY macropixels) of the original YUYV image // 4th Input: How much to subsample  // Pushing light data