class Labcom::ArcFrames

Authors

S.imazu

Version

22.0.0

Date

2020-07-31

Comment

Deprecated labcom module

[クラス名] ArcFrames

[説 明]

  1. 同一形式のフレームの集合体

[メンバー]

[クラスメソッド]

[インスタンスメソッド]

[UPDATE履歴]

18.0.0

初版

22.0.0

追加: converted_rgb()

[DEPRECATED]

This class is scheduled to be removed in the next version 26.0.0.

Attributes

bytes_per_sample[R]

1サンプルのバイト数

frames[R]

Frame データ配列

image_type[R]

イメージタイプ

na_type[R]

NArrayデータ型

x_size[R]

X方向サイズ

y_size[R]

Y方向サイズ

Public Class Methods

new( i_type, x_size, y_size) click to toggle source
引 数
i_type (string)

イメージタイプ

x_size (int)

X方向サイズ

y_size (int)

Y方向サイズ

例 外

TypeError:to_narray_type

説 明

コンストラクタ
イメージタイプ: ‘GRAY8’, ‘GRAY10’, ‘GREY8’, ‘GREY10’, ‘RGB’, ‘YUV’,…

# File lib/labcom/ArcFrames.rb, line 131
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

Public Instance Methods

add_frame( binary_str, bsize=nil) click to toggle source
引 数
binary_str (string)

データ配列(binary string)

bsize (int)

有効バイトデータサイズ

返 値

なし

例 外

RuntimeError

説 明

1フレームのデータを追加する。

# File lib/labcom/ArcFrames.rb, line 167
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
converted_rgb() click to toggle source
引 数

なし

返 値

4次元配列オブジェクト(NArray)

例 外

RuntimeError

説 明

フレームデータをNArrayクラスの4次元配列オブジェクトで戻す。

# File lib/labcom/ArcFrames.rb, line 232
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
num() click to toggle source
引 数

なし

返 値

フレーム件数(int)

説 明

データ配列のデータ件数ではない。

# File lib/labcom/ArcFrames.rb, line 185
def num()
  if nil != @frames then
    return @frames.length
  end
  return nil
end
val() click to toggle source
引 数

なし

返 値

3次元配列オブジェクト(NArray)

例 外

RuntimeError

説 明

フレームデータをNArrayクラスの3次元配列オブジェクトで戻す。

# File lib/labcom/ArcFrames.rb, line 203
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