Exemplo n.º 1
0
def test_get_morph():
    """Can we get the proper morphology type?"""
    ID = 'OGLE-BLG-ECL-040474'
    P = 1.8995918
    t0 = 7000.90650

    path_to_ogle = 'http://ogledb.astrouw.edu.pl/~ogle/OCVS/data/I/' + ID[
        -2:] + '/' + ID + '.dat'
    lc = np.loadtxt(path_to_ogle).T

    time = lc[0]
    mag = lc[1]
    err = lc[2]

    pf = Polyfitter(scale='mag')
    t0new, phase, polyfit, messages = pf.get_polyfit(time, mag, err, P, t0)

    assert_array_almost_equal(pf.c, np.array([0.42073795]))

    assert_array_almost_equal(pf.get_c(np.vstack((polyfit, polyfit))),
                              np.array([0.42073795, 0.42073795]))
Exemplo n.º 2
0
import cv2
import numpy as np
from thresholder import Thresholder
from warper import Warper
from polyfitter import Polyfitter
from polydrawer import Polydrawer

if __name__ == '__main__':
    cap = cv2.VideoCapture(0)
    threshold_object = Thresholder()
    warp_object = Warper()
    fitt_object = Polyfitter()
    draw_object = Polydrawer()

    while (cap.isOpened()):
        ret, color = cap.read()
        print color.shape
        th = threshold_object.threshold(color)
        # cv2.imshow('Combined', threshold_object.threshold(color))
        # cv2.imshow('Warped', warp_object.warp(th))
        img = warp_object.warp(th)
        left_fit, right_fit = fitt_object.polyfit(img)
        print left_fit, right_fit
        img = draw_object.draw(color, left_fit, right_fit, warp_object.Minv)
        cv2.imshow('Lane Detection', img)
        if cv2.waitKey(1) & 0xFF == 27:
            break

cv2.destroyAllWindows()
    t0 = 7000.90650

    # Load light curve from OGLE database
    # This is in magnitude scale
    path_to_ogle = 'http://ogledb.astrouw.edu.pl/~ogle/OCVS/data/I/' + ID[
        -2:] + '/' + ID + '.dat'
    lc = np.loadtxt(path_to_ogle).T

    # For clarity
    time = lc[0]
    mag = lc[1]
    err = lc[2]

    # Create Polyfitter instance by setting the brightness scale of your data
    # Set "mag" or "flux" scale
    pf = Polyfitter(scale='mag')

    # Run polynomial chain fitting
    t0new, phase, polyfit, messages = pf.get_polyfit(time, mag, err, P, t0)

    # Plot and save phase curve and polyfit
    plt.errorbar((time - t0new) / P % 1, mag, err, fmt='k.')
    plt.errorbar((time - t0new) / P % 1 - 1, mag, err, fmt='k.')
    plt.plot(phase, polyfit, c='r', zorder=10)
    plt.plot(phase + 1, polyfit, c='r', zorder=10)
    plt.xlabel('Phase')
    plt.ylabel('Magnitude')
    plt.xlim(-0.5, 1)
    plt.gca().invert_yaxis()
    plt.tight_layout()
    plt.savefig(ID + '.pdf')
Exemplo n.º 4
0
import os
import numpy as np
#from matplotlib import pyplot as pp
#from moviepy.video.io.VideoFileClip import VideoFileClip
from scipy import misc

from polydrawer import Polydrawer
from polyfitter import Polyfitter
from thresholder import Thresholder
#from undistorter import Undistorter
from warper import Warper

#undistorter = Undistorter()
thresholder = Thresholder()
warper = Warper()
polyfitter = Polyfitter()
polydrawer = Polydrawer()


def processImg(im):
    # mode = '1'
    # if mode == '0':
    #     video = 'project_video'
    #     white_output = '{}_done.mp4'.format(video)
    #     clip1 = VideoFileClip('{}.mp4'.format(video)).subclip(0,50)
    #     white_clip = clip1.fl_image(process_image)
    #     white_clip.write_videofile(white_output, audio=False)
    # else:
    # test_img = sys.argv[1]
    # im = misc.imread(test_img, mode='RGB')
    return process_image(im)
Exemplo n.º 5
0
    def depth_callback(self, data):
        try:
            global depth
            depth = self.bridge.imgmsg_to_cv2(data, "32FC1")
            # cv_image.astype('uint8')
        except CvBridgeError as e:
            print(e)
        # out.write(cv_image)
        # print depth.shape
        # cv2.imshow('Depth', depth)
        # cv2.waitKey(1)


if __name__ == '__main__':
    rospy.init_node('image_display', anonymous=True)
    threshold_object = Thresholder()
    warp_object = Warper()
    fitt_object = Polyfitter()
    draw_object = Polydrawer()
    # fourcc = cv2.VideoWriter_fourcc('M', 'J', 'P', 'G')
    fourcc = cv2.VideoWriter_fourcc(*'XVID')
    out = cv2.VideoWriter('test.avi', fourcc, 30.0, (1080, 720))
    image_object = Image_process()
    try:
        rospy.spin()
    except KeyboardInterrupt:
        rospy.is_shutdown()
        print 'Shutting Down'
        out.release()
    cv2.destroyAllWindows()
from moviepy.video.io.VideoFileClip import VideoFileClip
from scipy import misc
from moviepy.editor import *
from moviepy.video.tools.segmenting import findObjects
from polydrawer import Polydrawer
from polyfitter import Polyfitter
from thresholder import Thresholder
from undistorter import Undistorter
from warper import Warper
from roi import ROI


undistorter = Undistorter()
thresholder = Thresholder()
warper = Warper()
polyfitter = Polyfitter()
polydrawer = Polydrawer()
roi=ROI()

def main():
#input name here..

	clip_name='two'
	clip_fullname='{}.png'.format(clip_name)
	path='./inputimages/'
    clip_in=path+clip_fullname
    clip1=ImageClip(clip_in)
    time_name= time.strftime("%Y%m%d-%H%M%S")
	white_clip = clip1.fl_image(process_image)
	a='{}_{}.jpg'.format(clip_name,time_name)
	white_clip.save_frame(a)