示例#1
0
def picam_capture():
    iv = ivport.IVPort(ivport.TYPE_QUAD2, iv_jumper='A')
    iv.camera_open()
    iv.camera_change(1)
    iv.camera_capture("picam", use_video_port=False)
    iv.camera_change(2)
    iv.camera_capture("picam", use_video_port=False)
    iv.close()
示例#2
0
def picam_capture():
    iv = ivport.IVPort(ivport.TYPE_DUAL2)
    iv.camera_open()
    iv.camera_change(1)
    iv.camera_capture("picam", use_video_port=False)
    iv.camera_change(2)
    iv.camera_capture("picam", use_video_port=False)
    iv.close()
示例#3
0
def main():
    pub1 = rospy.Publisher('camera_topic1', Image, queue_size=10)  #2 topica
    pub2 = rospy.Publisher('camera_topic2', Image, queue_size=10)
    rospy.init_node('camera_publish_node', anonymous=True)
    rate = rospy.Rate(5)  #vise, brze
    bridge = CvBridge()

    iv = ivport.IVPort(ivport.TYPE_DUAL2)
    iv.camera_open(camera_v2=True)  #za sequenace camera_v2 = True
    i = 0

    #pogledaj u camera_publish_node.launch, ne kuzim zakaj ovo ne radi
    #dir = rospy.get_param('~dir')
    #print(dir) #/home/ivona-rpi/proba_ws/src/paket
    #dir = dir+'/'
    #print(dir) #/home/ivona-rpi/proba_ws/src/paket/

    dir = '/home/ivona-rpi/proba_ws/src/rpi-ivport/'

    #stvaranje foldera cam1_frames i cam2_frames, brisanje nakon svakog pokretanja

    for j in range(1, 3):
        if not os.path.exists(dir + '/cam' + str(j) + '_frames'):
            os.makedirs(dir + '/cam' + str(j) + '_frames')
        else:
            empty_folder(dir + '/cam' + str(j) + '_frames')

    while not rospy.is_shutdown():

        iv.camera_change(1)
        iv.camera_capture('picam', use_video_port=True)
        image = cv2.imread(dir + '/src/picam_CAM1.jpg')
        cv2.imwrite(dir + '/cam1_frames/' + str(i) + '.jpg', image)
        #print(image.shape) #480x720x3
        #print(image.dtype) #uint8
        image = np.uint8(image)

        image_message = bridge.cv2_to_imgmsg(image, encoding="passthrough")
        rospy.loginfo(image)
        pub1.publish(image_message)
        print('I publish1')
        rate.sleep()

        iv.camera_change(2)
        iv.camera_capture('picam', use_video_port=True)
        image = cv2.imread(dir + '/src/picam_CAM2.jpg')
        cv2.imwrite(dir + '/cam2_frames/' + str(i) + '.jpg', image)
        image = np.uint8(image)

        image_message = bridge.cv2_to_imgmsg(image, encoding="passthrough")
        rospy.loginfo(image)
        pub2.publish(image_message)
        print('I publish2')
        rate.sleep()

        i += 1

    iv.close()
示例#4
0
def still_capture2():
    # raspistill capture
    def capture(camera):
        "This system command for raspistill capture"
        cmd = "raspistill -t 10 -o still_CAM%d.jpg" % camera
        os.system(cmd)

    ivA = ivport.IVPort(ivport.TYPE_QUAD2, iv_jumper='A')
    ivA.camera_change(1)
    capture(1)
    # ivA.camera_change(2)
    # capture(2)
    # ivA.camera_change(3)
    # capture(3)

    ivB = ivport.IVPort(ivport.TYPE_QUAD2, iv_jumper='B')
    ivB.camera_change(2)
    ivA.camera_change(4)
    capture(2)
    ivA.close()
    ivB.close()
示例#5
0
def still_capture():
    # raspistill capture
    def capture(camera):
        "This system command for raspistill capture"
        cmd = "raspistill -t 10 -o still_CAM%d.jpg" % camera
        os.system(cmd)

    iv = ivport.IVPort(ivport.TYPE_DUAL2)
    iv.camera_change(1)
    capture(1)
    iv.camera_change(2)
    capture(2)
    iv.close()
示例#6
0
def main():
    print "beginning of main"
    if camera_v2 is True:
        iviic = IIC.IIC(addr=(0x70), bus_enable=(0x01))
    print "right after iviic = IIC.IIC...."
    camera_list = range(1, 5)
    print camera_list
    #picam_capture_into_files()
    #exit()

    iv = ivport.IVPort(board_type, iv_jumper='A')
    print "right after iv = ivport.IVPort(...."
    iv.camera_open(camera_v2=camera_v2)
    print "right after iv.camear_open"
    time.sleep(2.0)
    print "stop to sleep"

    #for i in range(1, 2):
    #   cv2.namedWindow( windows_name_by_id(i) )

    while True:
        images = {}
        print "right after images = {}"

        # first take all the images and store them
        for i in camera_list:
            image_new = get_one_image_by_cameraId(iv, i)
            #cv2.imshow( windows_name_by_id(i) , image_new)
            images[windows_name_by_id(i)] = image_new
            #print "taking new image port %u windows_name:%s" % (i,  windows_name_by_id(i))

        print "got the images"
        # print all the images
        for i in camera_list:
            image_new = images[windows_name_by_id(i)]
            cv2.imshow(windows_name_by_id(i), image_new)
            #images[windows_name_by_id(i)] = image_new

            #print "taking new image port %u windows_name:%s" % (i,  windows_name_by_id(i))

        key = cv2.waitKey(1)
        if key == ord("q"):  # if the `q` key was pressed, break from the loop
            break

    cv2.destroyAllWindows()
示例#7
0
def picam_sequence():
    FRAMES = 30
    CAM = 0
    def sequence_outputs(iv):
        frame = 0
        while frame < FRAMES:
            camera = (frame%2)+1
            time.sleep(0.2)   # SD Card Bandwidth Correction Delay
            iv.camera_change(camera)
            time.sleep(0.2)   # SD Card Bandwidth Correction Delay
            yield 'sequence_%02d.jpg' % frame
            frame += 1
            print camera

    iv = ivport.IVPort(ivport.TYPE_QUAD2, iv_jumper='A')
    iv.camera_open(camera_v2=True, resolution=(640, 480), framerate=60)
    #iv.picam.resolution = (640, 480)
    #iv.picam.framerate = 30
    #time.sleep(1)
    iv.camera_sequence(outputs=sequence_outputs(iv), use_video_port=True)
    iv.close()
示例#8
0
def picam_capture_into_files():
    iv = ivport.IVPort(board_type, iv_jumper='A')
    iv.camera_open(camera_v2=camera_v2)
    iv.camera_change(1)
    iv.camera_capture("picam", use_video_port=False)

    iv.camera_change(2)
    iv.camera_capture("picam", use_video_port=False)
    iv.camera_change(3)
    iv.camera_capture("picam", use_video_port=False)
    iv.camera_change(4)
    iv.camera_capture("picam", use_video_port=False)

    img = cv2.imread('picam_CAM1.jpg')
    cv2.imshow("desparateWindows1", img)
    img = cv2.imread('picam_CAM2.jpg')
    cv2.imshow("desparateWindows2", img)

    print "press any key to exit"
    cv2.waitKey(0)
    print "just read my file"
    time.sleep(0.5)
    cv2.destroyAllWindows()
    iv.close()
示例#9
0
GPIO.setup(ECHO3,GPIO.IN)
GPIO.output(TRIG1, False)
print "Waiting For Sensor1 To Settle"
time.sleep(2)
GPIO.output(TRIG2, False)
print "Waiting For Sensor2 To Settle"
time.sleep(2)
GPIO.output(TRIG3, False)
print "Waiting For Sensor3 To Settle"
time.sleep(2)
GPIO.output(TRIG4, False)
print "Waiting For Sensor4 To Settle"
time.sleep(2)

#Camera multiplexer setup
iv = ivport.IVPort(ivport.TYPE_DUAL2)

camera = picamera.PiCamera()

cur_camera = 1 #1 is IR 2 is Visible light
talons = 0	#0 is open 1 is closed

def getTemperature(pin):

	temp = GPIO.input(pin)
	camera.annotate_text = temp
	return temp
	
def openTalons():
	
	for pulse in range(50, 250, 1):
示例#10
0
from utils import *
#import picamera
import ivport
import time
import os

if __name__ == '__main__':
    to_measure = True
    to_plot = not to_measure

    if to_measure:
        os.system('~/Downloads/ivport-v2/init_ivport.py')
        os.system('~/Downloads/ivport-v2/vcgencmd get_camera')
        os.system('~/Downloads/ivport-v2/i2cdetect -y 1')

        iv = ivport.IVPort(ivport.TYPE_QUAD2)
        iv.camera_change(1)
        iv.camera_open(resolution=(1920, 1080), framerate=24)

        #camera = picamera.PiCamera()
        #camera.resolution = (1920,1080)
        #camera.framerate=24
        time.sleep(2)
        #img = snapshot(iv.camera)
        iv.camera_capture('single')
        #print(np.array_repr(img))
        iv.close()

    if to_plot:
        exit()