Authors
S.imazu
Version
22.0.0
Date
2020-07-31
イメージタイプ
NArrayデータ型
1サンプルのバイト数
X方向サイズ
Y方向サイズ
フレームデータ配列
new( binary_str, bsize=nil)
add_frame( binary_str, bsize=nil)
同一形式のフレームの集合体
18.0.0 初版 22.0.0 追加:converted_rgb()
イメージタイプ
[ #x_size(int) ] X方向サイズ [ #y_size(int) ] Y方向サイズ
TypeError:to_narray_type
[説 明] コンストラクタ イメージタイプ: 'GRAY8', 'GRAY10', 'GREY8', 'GREY10', 'RGB', 'YUV',...
# File labcom/ArcFrames.rb, line 123 def initialize( i_type, x_size, y_size) @image_type = i_type @x_size = x_size @y_size = y_size @na_type = Labcom::to_narray_type( i_type ) @bytes_per_sample = Labcom::to_bytes_per_sample( i_type ) @frames = [] end
データ配列(binary string)
有効バイトデータサイズ
なし
RuntimeError
[説 明] 1フレームのデータを追加する。
# File labcom/ArcFrames.rb, line 150 def add_frame( binary_str, bsize=nil) if nil != @frames then @frames.push(Frame.new(binary_str, bsize)) else raise RuntimeError, 'No initialize frames.' end end
なし
4次元配列オブジェクト(NArray)
RuntimeError
[説 明] フレームデータをNArrayクラスの4次元配列オブジェクトで戻す。
# File labcom/ArcFrames.rb, line 217 def converted_rgb() sz = num() return nil if nil == sz sy = @y_size sx = @x_size fr_size = sy*sx if( @image_type == 'YUV422') then ary_4d = NArray.new(NArray::BYTE, 3,sx,sy,sz) for fr in 0..sz-1 do if fr_size != @frames[fr].byte_length/@bytes_per_sample then raise RuntimeError, 'Illegal frame object size' end rgb_bin = Retrieve.rgb_from_yuv422(@frames[fr].block_bin_str, @frames[fr].byte_length(),0 ) ary_4d[0..-1,0..-1,0..-1,fr] = NArray.to_na( rgb_bin , NArray::BYTE, 3, sx, sy) end return ary_4d elsif( @image_type == 'YUY2') then ary_4d = NArray.new(NArray::BYTE, 3,sx,sy,sz) for fr in 0..sz-1 do if fr_size != @frames[fr].byte_length/@bytes_per_sample then raise RuntimeError, 'Illegal frame object size' end rgb_bin = Retrieve.rgb_from_yuy2(@frames[fr].block_bin_str, @frames[fr].byte_length() ) ary_4d[0..-1,0..-1,0..-1,fr] = NArray.to_na( rgb_bin , NArray::BYTE, 3, sx, sy) end return ary_4d end return nil end
なし
フレーム件数(int)
[説 明] データ配列のデータ件数ではない。
# File labcom/ArcFrames.rb, line 169 def num() if nil != @frames then return @frames.length end return nil end
なし
3次元配列オブジェクト(NArray)
RuntimeError
[説 明] フレームデータをNArrayクラスの3次元配列オブジェクトで戻す。
# File labcom/ArcFrames.rb, line 188 def val() sz = num() return nil if nil == sz sy = @y_size sx = @x_size fr_size = sy*sx ary_3d = NArray.new(@na_type, sx,sy,sz) for fr in 0..sz-1 do if fr_size != @frames[fr].byte_length/@bytes_per_sample then raise RuntimeError, 'Illegal frame object size' end ary_3d[0..-1,0..-1,fr] = NArray.to_na( @frames[fr].block_bin_str , @na_type, sx, sy) end return ary_3d end