Quantcast
Channel: Node.jsタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 8701

80mm フィルム (58mm フィルム) を発明してみた

$
0
0

レシート用のサーマルロール紙 (幅 80 mm or 58 mm) を映画のフィルムにしちゃいます!

01.jpg

receiptline シリーズ最終回では、インスタントカメラを作って、最後にレシートプリンターを自撮り連写しました。
この写真を眺めていたら、動画もできるんじゃないか?と思ったのです。

02.jpg

自動用紙カットを解除

receiptlineは、印刷が終わると用紙を自動でカットしてくれます。
映画のフィルムにするには、この自動用紙カットを解除しなくてはなりません。
変換ライブラリ lib/receiptline.jsのソースコードを調べます。

lib/receiptline.js
//// ESC/POS//const_escpos={// start printing: ESC @ GS a n ESC M n FS ( A pL pH fn m ESC SP n FS S n1 n2 ESC 3 n ESC { nopen:printer=>'\x1b@\x1da\x00\x1bM0\x1c(A'+$(2,0,48,0)+'\x1b \x00\x1cS\x00\x00\x1b3\x00\x1b{'+$(printer.upsideDown),// finish printing: GS r nclose:function(){returnthis.cut()+'\x1dr1';},

見つけました。close メソッドの this.cut() +を削除します。

lib/receiptline.js
//// ESC/POS//const_escpos={// start printing: ESC @ GS a n ESC M n FS ( A pL pH fn m ESC SP n FS S n1 n2 ESC 3 n ESC { nopen:printer=>'\x1b@\x1da\x00\x1bM0\x1c(A'+$(2,0,48,0)+'\x1b \x00\x1cS\x00\x00\x1b3\x00\x1b{'+$(printer.upsideDown),// finish printing: GS r nclose:function(){// return this.cut() + '\x1dr1';return'\x1dr1';},

インスタントカメラを改造

インスタントカメラのコードと実行環境を流用します。
映像クリックで撮影開始/終了するように変更しました。

wwwroot/index.html
<!DOCTYPE html><html><head><metacharset="utf-8"><title>80mm Film Camera</title><script type="text/javascript">asyncfunctioninitialize(){constvideo=document.querySelector('video');constcanvas=document.querySelector('canvas');lettimer=0;// videovideo.srcObject=awaitnavigator.mediaDevices.getUserMedia({audio:false,video:{width:1280,height:720}});video.onclick=event=>{if(timer>0){// stopclearInterval(timer);timer=0;}else{// starttimer=setInterval(()=>{// imagecanvas.getContext('2d').drawImage(video,0,0,canvas.width,canvas.height);letdata=`{i:${canvas.toDataURL('image/png').slice(22)}}\n`;// barcodeconstnow=newDate();constiso=newDate(now.getTime()-now.getTimezoneOffset()*60000).toISOString();data+=`{c:${iso.replace(/\D/g,'').slice(2,14)};o:ean,24}|`;// send dataconstxhr=newXMLHttpRequest();xhr.open('POST','printer');xhr.setRequestHeader('Content-Type','text/plain; charset=utf-8');xhr.send(data);},2000);}};}</script></head><bodyonload="initialize()"><videoautoplaystyle="width: 100%;"></video><canvaswidth="512"height="288"style="display: none;"></canvas></body></html>
  • レシートプリンター
    • TM-T88V (80mm)
  • 記録メディア
    • 80 ミリフィルム (80mm 幅のサーマルロール紙)
  • アスペクト比
    • 16 : 9
  • 画素数
    • 512 x 288 ピクセル
  • フレームレート
    • 0.5 fps (2 秒間隔で印刷)
  • 音声
    • なし

ストリームデータ処理にすれば、もっとフレームレートを上げられると思います。

80 ミリカメラ

80 ミリカメラのハードウェアです。家にあるものを組み合わせました。

03.jpg

  • ノートパソコン (カメラデバイス)
  • レシートプリンター
  • AC アダプタ
  • LAN ケーブル
  • ポータブル電源
  • ベビーキャリア

レシートプリンターが据え置き型なので重装備になってしまいました。
撮影しているとフィルムがはみ出してくるので、巻き取り装置がほしいです。

80 ミリ映写機

80 ミリ映写機は、まだこれから。そこで・・・

撮影済みのフィルムをイメージスキャナで取り込んで GIF アニメーションを作りました。
倍速でお届けします!

04.gif

05.gif

06.gif

いかがでしょうか?
また何か作ったら投稿します。ではまた!


Viewing all articles
Browse latest Browse all 8701

Trending Articles