Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functs get timestamp and save as png with opts #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions src/flycapture2.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ cdef class Context:
"min_num_image_notifications": config.minNumImageNotifications,
"grab_timeout": config.grabTimeout,
"grab_mode": config.grabMode,
"high_performance_retrieve_buffer": config.highPerformanceRetrieveBuffer,
#"high_performance_retrieve_buffer": config.highPerformanceRetrieveBuffer,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated.changes?

"isoch_bus_speed": config.isochBusSpeed,
"async_bus_speed": config.asyncBusSpeed,
"bandwidth_allocation": config.bandwidthAllocation,
Expand All @@ -408,7 +408,7 @@ cdef class Context:
config.minNumImageNotifications = min_num_image_notifications
config.grabTimeout = grab_timeout
config.grabMode = grab_mode
config.highPerformanceRetrieveBuffer = high_performance_retrieve_buffer
#config.highPerformanceRetrieveBuffer = high_performance_retrieve_buffer
config.isochBusSpeed = isoch_bus_speed
config.asyncBusSpeed = async_bus_speed
config.bandwidthAllocation = bandwidth_allocation
Expand Down Expand Up @@ -642,3 +642,33 @@ cdef class Image:

def get_format(self):
return self.fmt or self.img.format

def get_timestamp(self):
with nogil:
ts=fc2GetImageTimeStamp( &self.img)
return ts

def save_as_png(self,filename):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be save_image() and the format choice should be exposed as an argument in a suitable way.

cdef fc2ImageFileFormat format
format=PNG
pystring=filename.encode('utf-8')
cdef char* filename_c=pystring
with nogil:
fc2SaveImage( &self.img, filename_c, format )

def save_as_pngwithopt(self,filename,compressionlevel=1,interlaced=False):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

cdef fc2PNGOption option
option.compressionLevel=compressionlevel
option.interlaced=interlaced
cdef fc2ImageFileFormat format
format=PNG

pystring=filename.encode('utf-8')
cdef char* filename_c=pystring

with nogil:
fc2SaveImageWithOption(&self.img, filename_c, format, &option)