Setting Exposure Time via Node Map

acquisition
#1

Hi, in relation to your posts, i’m attempting to take consecutive photo’s with increasing exposure time, but i’m unsure how to alter the node value for exposure time?

this is what i have

import os
import cvb

with cvb.DeviceFactory.open(os.path.join(cvb.install_path(), "drivers", "GenICam.vin"), port=0) as device:
    
    stream = device.stream
    stream.start()
    device_node_map = device.node_maps["Device"]
    #exposure = device_node_map["ExposureTime"]

    for i in range(10):
        
        device_node_map["ExposureTime"].value(i*1000)
        
    
        img, status = stream.wait()
        
     
        if status == cvb.WaitStatus.Ok:
            print("Acquired image: " + str(i))
        
        img.save("C:\\Users\\TechHP1\\Pictures\\newattempt" + str(i) + ".jpg")

        
    stream.stop()

anyone have any ideas?

1 Like
Getting Started with CVBpy
#2

Hi @Adam,

can you tell us more what actually is wrong with your code? On the first look this code seems ok to me.

Only thing I can imagine is that if the camera is in freerun mode you might be to slow to change exposure settings for each frame. Better would be to use a software- or hardware trigger.

regards,
Theo

@illusive, can we copy this question to a new topic?

#3

Hi, i managed to get it to work but i had to change the exposure time variable to a string and use the from_string function, i couldn’t get the value function to work. The code below works as intended though if anyone ever wants to use it

import os
import cvb


with cvb.DeviceFactory.open(os.path.join(cvb.install_path(), "drivers", "GenICam.vin"), port=0) as device:

#opens the camera
    
    stream = device.stream
    stream.start()

    #starts streaming

    device_node_map = device.node_maps["Device"]

    #calls the node map

    for i in range(10):
        exposure=(i+1)*10000
        val = str(exposure)

	#change exposure to a string and define variable

        device_node_map["ExposureTime"].from_string(val)

	#this changes the exposure time to whatever value val has        
    
        img, status = stream.wait()

	#waits till next image is ready and takes it        
     
        if status == cvb.WaitStatus.Ok:
            print("Acquired image: " + str(i))
        
        img.save("C:\\Users\\TechHP1\\Pictures\\newattempt" + str(i) + ".jpg")

        
    stream.stop()
#4

Hi @Adam,

at first I missed your issue - but now I see.
Node.value is not a method but a property device_node_map["ExposureTime"].value = i * 1000 should work fine.

1 Like