Jolt360으로 찍은 360도 사진을 구글 카드보드 앱으로 보기...

Jolt 360 앱으로 찍은 dual fisheye 사진을 자체 앱을 이용해 stitch.
Stitch된 사진들은 Jolt 360 앱에서 정상적으로 볼 수 있지만, 구글 카드보드 앱과는 호환 안 됨.
구글 카드보드 앱을 이용하기 위해서는 두 가지 조치 필요.

1. Photospere 사진으로 인식되도록 파일명 변경
파일 이름이 'PANO_'로 시작해야 함.
파일명 일괄 변경 프로그램을 이용해서 쉽게 수정 가능하므로 자세한 설명은 생략한다!

2. 180도 회전
Jolt 360으로 봤을 때 정면이, 구글 카드보드로 보면 뒷면으로 보인다. 180도 회전 필요하다는 말.
공개 소프트웨어인 Gimp와 Python-fu 스크립트(플러그인)를 이용해 일괄처리할 수 있다.
Gimp 사용법, 플러그인 설치 및 동작의 자세한 설명은 생략한다!
아래는 사용한 Python 스크립트.

#!/usr/bin/env python
#
#   File = rotate-jolt-image.py

from gimpfu import *
import os
import re

def rotateJoltImage(srcPath, tgtPath):
  open_images, image_ids = pdb.gimp_image_list()
  if open_images > 0:
    pdb.gimp_message("Close all images and try again.")
  else:
    allFileList = os.listdir(srcPath)
    existingList = os.listdir(tgtPath)
    if existingList != []:
      pdb.gimp_message("Empty the target directory and try again.")
    else:
      srcFileList = []
      xform = re.compile('\.jpg', re.IGNORECASE)
      # Find all of the jpeg files in the list & make xcf file names
      for fname in allFileList:
        fnameLow = fname.lower()
        if fnameLow.count('.jpg') > 0:
          srcFileList.append(fname)
          # Loop on jpegs
      for srcFile in srcFileList:
        # os.path.join inserts the right kind of file separator
        tgtFile = os.path.join(tgtPath, xform.sub('_rot180.jpg', srcFile))
        srcFile = os.path.join(srcPath, srcFile)
        theImage = pdb.file_jpeg_load(srcFile, srcFile)
        #
        org_layer = pdb.gimp_image_get_active_layer(theImage)
        pdb.gimp_layer_add_alpha(org_layer)
        new_layer = pdb.gimp_layer_copy(org_layer, TRUE)
        pdb.gimp_image_insert_layer(theImage, new_layer, None, -1)
        #
        pdb.gimp_image_set_active_layer(theImage, org_layer)
        pdb.gimp_image_select_rectangle(theImage, 2, 0, 0, theImage.width/2, theImage.height)
        pdb.gimp_selection_invert(theImage)
        pdb.gimp_edit_clear(pdb.gimp_image_get_active_drawable(theImage))
        pdb.gimp_layer_translate(org_layer, theImage.width/2, 0)
        #
        pdb.gimp_image_set_active_layer(theImage, new_layer)
        pdb.gimp_image_select_rectangle(theImage, 2, 0, 0, theImage.width/2, theImage.height)
        pdb.gimp_edit_clear(pdb.gimp_image_get_active_drawable(theImage))
        pdb.gimp_layer_translate(new_layer, -theImage.width/2, 0)
        #
        final_layer = pdb.gimp_image_merge_down(theImage, new_layer, 1)
        #
        pdb.gimp_file_save(theImage, final_layer, tgtFile, tgtFile)
        #
        pdb.gimp_image_delete(theImage)
        #

register (
    "rotateJoltImage",         # Name registered in Procedure Browser
    "Rotate Stitched Image of Jolt Duo", # Widget title
    "Rotate Stitched Image of Jolt Duo", # 
    "Author Name",         # Author
    "Copyright Holder",         # Copyright Holder
    "Date",            # Date
    "Rotate by 180 degree", # Menu Entry
    "",     # Image Type - No image required
    [
    ( PF_DIRNAME, "srcPath", "Source Directory:", "/default" ),
    ( PF_DIRNAME, "tgtPath", "Target Directory:", "/default" ),
    ],
    [],
    rotateJoltImage,   # Matches to name of function being defined
    menu = "<Image>/JoltDuo-Py"  # Menu Location
    )   # End register

main()

댓글

이 블로그의 인기 게시물

환경개선부담금

[DevTip] Windows에서 tail 쓰기...