Skip to content

Commit

Permalink
impro function application while save and get image
Browse files Browse the repository at this point in the history
  • Loading branch information
mbalatsko committed Oct 30, 2018
1 parent 7c80a84 commit 4cff612
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def impro(img):
#### Viewer
We have prepared all required parts. Now we just set them to the viewer object and launch image grabbing:
`run_interaction_continuous_shot` for continuous or `run_interaction_single_shot` for single shot.
Also you can press 'S' button to save raw camera image to `image_folder`.
Also you can press 'S' button to save raw camera image or impro function return value to `image_folder`.
```python
from pypylon_opencv_viewer import BaslerOpenCVViewer

Expand All @@ -128,7 +128,7 @@ procedure with the image, just change wanted values and push the button. That's
#### Save or get image from camera

In previous steps we set up camera features parameters using widgets. Now we can save camera image on disc or get
raw openCV image.
raw openCV image (impro function return value if specified).

```python
# Save image
Expand Down
19 changes: 12 additions & 7 deletions pypylon_opencv_viewer/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ def run_interaction_continuous_shot(self, grab_strategy=pylon.GrabStrategy_Lates
window_size=None, image_folder='.'):
""" Creates Jupyter notebook widgets with all specified features value controls. Push the button 'Run interact'
to run continuous image grabbing and applying image processing function, if specified. To close openCV windows
push 'q' button on your keyboard. Press 'S' button to save raw camera image.
push 'q' button on your keyboard. Press 'S' button to save raw camera image or impro function return value
if specified.
Parameters
----------
Expand All @@ -184,7 +185,7 @@ def run_interaction_continuous_shot(self, grab_strategy=pylon.GrabStrategy_Lates
def run_interaction_single_shot(self, window_size=None, image_folder='.'):
""" Creates Jupyter notebook widgets with all specified features value controls. Push the button 'Run interact'
to grab one image and apply image processing function, if specified. To close openCV windows push 'q' button on
your keyboard. Press 'S' button to save raw camera image.
your keyboard. Press 'S' button to save raw camera image or impro function return value if specified.
Parameters
----------
Expand All @@ -205,7 +206,7 @@ def run_interaction_single_shot(self, window_size=None, image_folder='.'):
def _continuous_interaction_function_wrap(self, grab_strategy, window_size=None, image_folder='.'):
""" Creates Jupyter notebook interact function, which sets up camera with input parameters and runs image
processing function on continuously grabbing images, if specified, if not displays continuously grabbing raw
amera images.
camera images.
Parameters
----------
Expand Down Expand Up @@ -248,7 +249,7 @@ def camera_configuration(**kwargs):
img = image.GetArray()

if self._impro_function is not None:
self._impro_function(img)
img = self._impro_function(img)
else:
cv2.imshow('camera_image', img)
k = cv2.waitKey(1) & 0xFF
Expand Down Expand Up @@ -305,7 +306,7 @@ def camera_configuration(**kwargs):
img = image.GetArray()

if self._impro_function is not None:
self._impro_function(img)
img = self._impro_function(img)
else:
cv2.imshow('camera_image', img)
while True:
Expand All @@ -321,7 +322,7 @@ def camera_configuration(**kwargs):
return camera_configuration

def save_image(self, filename):
"""Saves grabbed image
"""Saves grabbed image or impro function return value, if specified
Parameters
----------
Expand All @@ -342,10 +343,12 @@ def save_image(self, filename):
grab_result = self._camera.GrabOne(5000)
image = converter.Convert(grab_result)
img = image.GetArray()
if self._impro_function:
img = self._impro_function(img)
cv2.imwrite(filename, img)

def get_image(self):
"""Returns grabbed image
"""Returns grabbed image or impro function return value, if specified
Returns
-------
Expand All @@ -361,4 +364,6 @@ def get_image(self):
grab_result = self._camera.GrabOne(5000)
image = converter.Convert(grab_result)
img = image.GetArray()
if self._impro_function:
img = self._impro_function(img)
return img
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
jupyter==1.0.0
opencv-python==3.4.3.18
pypylon==1.3.1
ipython==6.5.0
ipywidgets==7.4.2
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@
setup(
name='pypylon-opencv-viewer',
packages=find_packages(),
version='1.0.2',
description='Save image, while interaction functionality',
version='1.0.3',
description='Impro function application while saving and getting image',
long_description=long_description,
long_description_content_type='text/markdown',
license='MIT License',
author='Maksym Balatsko',
author_email='mbalatsko@gmail.com',
url='https://github.com/mbalatsko/pypylon-opencv-viewer',
download_url='https://github.com/mbalatsko/pypylon-opencv-viewer/archive/1.0.2.tar.gz',
download_url='https://github.com/mbalatsko/pypylon-opencv-viewer/archive/1.0.3.tar.gz',
install_requires=[
'opencv-python',
'jupyter',
'pypylon',
'ipywidgets',
Expand Down

0 comments on commit 4cff612

Please sign in to comment.