下面提供了代码。
该行: device.set_string_feature_value('PixelCoding', 'Raw') 不起作用。它将pixelCoding默认为默认值(单声道)
我厌倦了把这些线: device.set_integer_feature_value('TLParamsLocked', 0) device.set_integer_feature_value('TLParamsLocked', 1) 看看这是否没有让参数更新,但这没有用。
如果您需要更多详细说明,请告诉我。
项目链接:https ://github.com/AravisProject/aravis
import sys
import gi
import numpy
gi.require_version('Aravis', '0.6')
from gi.repository import Aravis
Aravis.enable_interface("Fake")
try:
if len(sys.argv) > 1:
camera = Aravis.Camera.new(sys.argv[1])
else:
camera = Aravis.Camera.new(None)
except:
print("No camera found")
exit()
camera.set_region(0,0,512,640)
camera.set_frame_rate(30.0)
device = camera.get_device()
device.set_integer_feature_value('TLParamsLocked', 0)
device.set_string_feature_value('SensorGainMode', 'HighGainMode')
device.set_string_feature_value('TemperatureLinearMode', 'On')
device.set_string_feature_value('TemperatureLinearResolution', 'High')
device.set_string_feature_value('PixelFormat', 'MONO16')
print device.get_boolean_feature_value('TLParamsLocked')
device.set_string_feature_value('PixelCoding', 'Raw')
print("pixel coding")
print device.get_string_feature_value('PixelCoding')
print device.get_string_feature_value('PixelFormat')
payload = camera.get_payload()
[x,y,width,height] = camera.get_region()
print("Camera vendor : %s" %(camera.get_vendor_name()))
print("Camera model : %s" %(camera.get_model_name()))
print("Camera id : %s" %(camera.get_device_id()))
print("ROI : %dx%d at %d,%d" %(width, height, x, y))
print("Payload : %d" %(payload))
print("Pixel format : %s" %(camera.get_pixel_format_as_string()))
stream = camera.create_stream(None, None)
for i in range(0,10):
stream.push_buffer(Aravis.Buffer.new_allocate(payload))
print("Start acquisition")
camera.start_acquisition()
print("Acquisition")
for i in range(0,20):
buffer = stream.pop_buffer()
data = buffer.get_data()
img_data = numpy.ndarray(buffer=data, dtype=numpy.uint16, shape=(camera.get_region()[3], camera.get_region()[2], 1))
#print img_data[0]
#numpy.savetxt("foo.csv", img_data, delimiter=",")
if buffer:
stream.push_buffer(buffer)
print("Stop acquisition")
camera.stop_acquisition()
device.set_integer_feature_value('TLParamsLocked', 1 )