Пример #1
0
class HorizonTest(unittest.TestCase):

    #setUp
    def setUp(self):
	#create Grayscale picture for test
	testColorImg1 = cv.LoadImage("./HorizonTestData/test1.jpg",cv.CV_LOAD_IMAGE_COLOR)
	cv.Smooth(testColorImg1,testColorImg1,cv.CV_GAUSSIAN,13,0,0,0)
	testGrayImage1 = cv.CreateImage((testColorImg1.width,testColorImg1.height),cv.IPL_DEPTH_8U,1)
	cv.CvtColor(testColorImg1,testGrayImage1,cv.CV_BGR2GRAY)
	cv.EqualizeHist(testGrayImage1,testGrayImage1)
	#create instance
	self.horizon = Horizon(testGrayImage1)
	self.horizon.test(testColorImg1)
	

#    def testAll(self):
	#インスタンスが生成されていることを確認する
	#Tests exsit of instance
#	self.assertIsInstance(self.horizon,Horizon)

	
    #Tests calcHorizon
    def testDetectHough(self):
	self.assertIsInstance(self.horizon,Horizon)
	self.horizon.detectHorizon()
Пример #2
0
    def getHorizon(self):
	try:
	    self.getCameraCVPict()
	    self.convertGray()
	    horizon = Horizon(self.__grayCameraPict)
	    horizon.detectHorizon()
	    degree = horizon.getHorizon()
	    print "degree:"+str(degree)
	    return degree
	except:
	    sys.exit(sys.exc_info()[:2])
Пример #3
0
    def setUp(self):
	#create Grayscale picture for test
	testColorImg1 = cv.LoadImage("./HorizonTestData/test1.jpg",cv.CV_LOAD_IMAGE_COLOR)
	cv.Smooth(testColorImg1,testColorImg1,cv.CV_GAUSSIAN,13,0,0,0)
	testGrayImage1 = cv.CreateImage((testColorImg1.width,testColorImg1.height),cv.IPL_DEPTH_8U,1)
	cv.CvtColor(testColorImg1,testGrayImage1,cv.CV_BGR2GRAY)
	cv.EqualizeHist(testGrayImage1,testGrayImage1)
	#create instance
	self.horizon = Horizon(testGrayImage1)
	self.horizon.test(testColorImg1)
Пример #4
0
#!/ms/dist/python/PROJ/core/2.7.1/bin/python

import sys, ms.version
ms.version.addpkg('python_modules', '1.3', meta='horizon')
import Horizon, q

hz = Horizon.HzConnection()
conn = hz.connect(
    'pdbc:hrz://prod/?useIndex=y&moduleLoad=horizon:funcDSUtils:prod')

#query = "`vd xdesc getDSData `ids`sd`ed`cnames!(`UA.N;.z.d-10;.z.d-1;`id`vd`tp`tp_thic`ocp_dailyprc`cp_thic)"
query = "getDSData`cnames`sd`ed`where!(`id`vd`short_sell_volume;2013.01.27;2013.01.28;enlist (in;`e;enlist `KS`KQ))"
#query = "`vd xdesc .dsg2.getData `dname`tname`ids`cnames`sd`ed !(`ds2;`ds_price;`MS.N;`id`vd`rawtp`rawvs;`date$.z.Z-30;`date$.z.Z)"

res = hz.executeQuery(query)
print res

hz.disconnect()
Пример #5
0
class OpenStack:
    def __init__(self):
        pass

    _CONTROL_INSTALLERS = [{
        "name":
        "operating_system_control",
        "installer":
        OperatingSystem.OperatingSystem(control_node=True, node_type='control')
    }, {
        "name": "mysql",
        "installer": MySQL.MySQL()
    }, {
        "name": "rabbitmq",
        "installer": RabbitMQ.RabbitMQ()
    }, {
        "name": "keystone",
        "installer": Keystone.Keystone()
    }, {
        "name": "glance",
        "installer": Glance.Glance()
    }, {
        "name":
        "nova_control",
        "installer":
        Nova.Nova(control_node=True, node_type='control')
    }, {
        "name":
        "neutron_control",
        "installer":
        Neutron.Neutron(control_node=True, node_type='control')
    }, {
        "name": "horizon",
        "installer": Horizon.Horizon()
    }]

    _NETWORK_INSTALLERS = [{
        "name":
        "operating_system_network",
        "installer":
        OperatingSystem.OperatingSystem(control_node=False,
                                        node_type='network')
    }, {
        "name":
        "neutron_network",
        "installer":
        Neutron.Neutron(control_node=False, node_type='network')
    }]

    _COMPUTE_INSTALLERS = [{
        "name":
        "operating_system_compute",
        "installer":
        OperatingSystem.OperatingSystem(control_node=False,
                                        node_type='compute')
    }, {
        "name":
        "nova_compute",
        "installer":
        Nova.Nova(control_node=False, node_type='compute')
    }, {
        "name":
        "neutron_compute",
        "installer":
        Neutron.Neutron(control_node=False, node_type='compute')
    }]



    def createCommands(self, \
                           installers,
                           directory,
                           install_filename,
                           uninstall_filename):
        try:
            os.makedirs(directory)
        except OSError as exc:  # Python >2.5
            if exc.errno == errno.EEXIST and os.path.isdir(directory):
                pass
            else:
                raise

        install_file = open(directory + "/" + install_filename, 'w')
        uninstall_file = open(directory + "/" + uninstall_filename, 'w')

        for module in installers:
            module_name = module["name"]
            module_installer = module["installer"]

            if module_name != "operating_system_control" and module_name != "operating_system_compute" and module_name != "operating_system_network":
                install_file.write("%s/install_%s.sh\n" % \
                                   (directory, module_name))
                uninstall_file.write("%s/uninstall_%s.sh\n" % \
                                     (directory, module_name))

            self.installerCommands(directory, module_name, \
                                       module_installer, True)
            self.installerCommands(directory, module_name, \
                                       module_installer, False)

        install_file.close()
        uninstall_file.close()

    def installerCommands(self, dir, module_name, module_installer, install):
        prefix = "install"
        if not install:
            prefix = "uninstall"

        module_install_file = open("%s/%s_%s.sh" % (dir, prefix, module_name),
                                   "w")
        module_installer.clear()
        if install:
            module_installer.installCommands()
        else:
            module_installer.uninstallCommands()
        module_install_commands = module_installer.getCommands()
        for ic in module_install_commands:
            module_install_file.write(ic)
            module_install_file.write("\n")
        module_install_file.close()
Пример #6
0
            bar.set_postfix(acc='{:.5f}'.format(correct /
                                                int(labels_test.shape[0])),
                            loss='{:5f}'.format(current_loss))
            bar.update(1)

    bar.close()

    return val_loss, val_total, val_correct, val_confusion_matrix


if (__name__ == "__main__"):

    torch.backends.cudnn.benchmark = True

    Horizon.print_horizon("lean")

    sys.stdout = Logger(filename="logs/train.log", stream=sys.stdout)

    print("Checking      ......")

    args = get_args()

    check_args(args)

    print("Initializaion ......")

    normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406],
                                     std=[0.229, 0.224, 0.225])

    #prepare data