# Path: blockplayer/dataset.py
# def advance(skip=1):
# def setup_opencl():
# def load_dataset(pathname):
# def load_gt():
# def load_random_dataset():
# def download():
# 
# Path: blockplayer/normals.py
# def normals_opencl(depth, mask=None, rect=((0,0),(640,480)), win=6):
#     def from_rect(m,rect):
# def normal_show(nx,ny,nz):
# def normals_numpy(depth, rect=((0,0),(640,480)), win=7, mat=None):
# def normals_c(depth, rect=((0,0),(640,480)), win=7):
# def color_axis(normals,d=0.1):
#     X,Y,Z,W = -dx, -dy, 0*dy+1, -(-dx*u + -dy*v + depth).astype(np.float32)
#     X,Y,Z = [normals[:,:,i] for i in range(3)]
# 
# Path: blockplayer/preprocess.py
# def threshold_and_mask(depth,bg):
#     def m_():
#     def m2_():
#     def m3_():
# 
# Path: blockplayer/config.py
# def load(dir_path):
# def save(dir_path):
# LH = 0.0192
# LW = 0.016
# GRIDRAD = 18


from blockplayer import dataset
from blockplayer import normals
from blockplayer import preprocess
from blockplayer import config
import cv
import pylab
import numpy as np
# Andrew Miller <amiller@cs.ucf.edu> 2011
#
# BlockPlayer - 3D model reconstruction using the Lattice-First algorithm
# See: 
#    "Interactive 3D Model Acquisition and Tracking of Building Block Structures"
#    Andrew Miller, Brandyn White, Emiko Charbonneau, Zach Kanzler, and Joseph J. LaViola Jr.
#    IEEE VR 2012, IEEE TVGC 2012
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.



def show_mask(name, m, rect):
    im = cv.CreateImage((m.shape[1],m.shape[0]), 32, 3)
    cv.SetData(im, np.ascontiguousarray(np.dstack(3*[m])))
    (t,l),(b,r) = rect
    cv.Rectangle(im, (t,l), (b,r), (255,255,0))
    cv.ShowImage(name, im)


def once():
    dataset.advance()
    depthL,depthR = dataset.depthL,dataset.depthR
    maskL,rectL = preprocess.threshold_and_mask(depthL,config.bgL)

# Path: blockplayer/dataset.py
# def advance(skip=1):
# def setup_opencl():
# def load_dataset(pathname):
# def load_gt():
# def load_random_dataset():
# def download():
# 
# Path: blockplayer/normals.py
# def normals_opencl(depth, mask=None, rect=((0,0),(640,480)), win=6):
#     def from_rect(m,rect):
# def normal_show(nx,ny,nz):
# def normals_numpy(depth, rect=((0,0),(640,480)), win=7, mat=None):
# def normals_c(depth, rect=((0,0),(640,480)), win=7):
# def color_axis(normals,d=0.1):
#     X,Y,Z,W = -dx, -dy, 0*dy+1, -(-dx*u + -dy*v + depth).astype(np.float32)
#     X,Y,Z = [normals[:,:,i] for i in range(3)]
# 
# Path: blockplayer/preprocess.py
# def threshold_and_mask(depth,bg):
#     def m_():
#     def m2_():
#     def m3_():
# 
# Path: blockplayer/config.py
# def load(dir_path):
# def save(dir_path):
# LH = 0.0192
# LW = 0.016
# GRIDRAD = 18


# Path: demos/demo_preprocess.py
from blockplayer import dataset
from blockplayer import normals
from blockplayer import preprocess
from blockplayer import config
import cv
import pylab
import numpy as np

# Andrew Miller <amiller@cs.ucf.edu> 2011
#
# BlockPlayer - 3D model reconstruction using the Lattice-First algorithm
# See: 
#    "Interactive 3D Model Acquisition and Tracking of Building Block Structures"
#    Andrew Miller, Brandyn White, Emiko Charbonneau, Zach Kanzler, and Joseph J. LaViola Jr.
#    IEEE VR 2012, IEEE TVGC 2012
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.



def show_mask(name, m, rect):
    im = cv.CreateImage((m.shape[1],m.shape[0]), 32, 3)
    cv.SetData(im, np.ascontiguousarray(np.dstack(3*[m])))
    (t,l),(b,r) = rect
    cv.Rectangle(im, (t,l), (b,r), (255,255,0))
    cv.ShowImage(name, im)


def once():
    dataset.advance()
    depthL,depthR = dataset.depthL,dataset.depthR
    maskL,rectL = preprocess.threshold_and_mask(depthL,config.bgL)

    maskR,rectR = preprocess.threshold_and_mask(depthR, config.bgR)