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

Adding some features to openCV / Touchscreen #530

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

lucpolak
Copy link

Added some usefull features to opencv when using a Webcam :

  • Adding support of selecting FOURCC (usually use YUY2) you can now select MJPEG which is compressed to have better performances)
  • Allow selecting V4L backend instead of GSTREAMER
  • Adding possibility to change the preview resolution (for c920, the native resolution is 1920 x 1080 but i don't know why V4L list a 2304x1536 resolution which is selected by defaut, causing a very laggy capture. So now, you can select a lower preview res (800x 600 to gain a lot of FPS

For touchscreen, allow a fullwidth intro screen

Copy link
Member

@werdeil werdeil left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this pull request, I haven't tested but it seems very promising for the opencv part. I have though some comments mainly to be sure that the code is not getting unnecessary parameters. I hope we can find way to merge it.

Comment on lines +125 to +130
# Use V4L2 instead of GSTREAMER
use_v4l2 = False

# Custom FourCC (can be YUY2 or MJPG or any other fourcc or None to use the default)
custom_fourcc = None

Copy link
Member

Choose a reason for hiding this comment

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

I'm not very fan to add opencv only settings in the config (I don't think we have this right now)

Copy link
Author

Choose a reason for hiding this comment

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

what do you suggest ? Perhaps create a specific bloc in configuration for opencv [OPENCV] in the ini file ?

Copy link
Member

Choose a reason for hiding this comment

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

As discussed in another comment, at least put more info that these parameters are only used for opencv camera

Copy link
Author

Choose a reason for hiding this comment

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

I've already finished a refactor with a dedicated [OPENCV] configuration section. ^^

self.delete_internal_memory = False
self.preview_rotation, self.capture_rotation = (0, 0)
self.preview_iso, self.capture_iso = (100, 100)
self.preview_flip, self.capture_flip = (False, False)
self.custom_fourcc = "Default"
Copy link
Member

Choose a reason for hiding this comment

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

Same kind of comment: the fourcc part shall not be in the base camera

Copy link
Author

Choose a reason for hiding this comment

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

Yes you're right, i will try to move it to OpenCV class

Copy link
Author

Choose a reason for hiding this comment

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

If I want to mode some opencv specific configuration values, i think i will need to refactor the configuration of the cameras. Currentyl, some "general" parameters like iso, resolution (delete_internal_memory <== Specific paramter) are passed directly) to the initialize method. But all the cameras does not share the same parameters. IMHO it will be better to passe the cfg to each derived class and each class will retrieve the custom parameters according to its need . How do you think about this solution ?

Copy link
Member

Choose a reason for hiding this comment

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

Indeed, you are right we already have exception and it needs a bigger change to work differently. I think the best is to avoid making a bigger change in this PR and keep it like it, maybe just be more explicit on the parameters name like opencv_use_v4l2 and opencv_custom_fourcc or at least be explicit in the config.py file that these parameters are used only for opencv cameras

@@ -248,7 +248,7 @@ def show_intro(self, pil_image=None, with_print=True):
else:
self._update_background(background.IntroBackground(self.arrow_location, self.arrow_offset))

if pil_image:
if with_print and pil_image:
Copy link
Member

Choose a reason for hiding this comment

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

Why adding this criteria?

Copy link
Author

Choose a reason for hiding this comment

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

I need this test for the fullscreen intro screen, without it, the text and the previous image will overlap together

@@ -498,7 +501,7 @@ def resize(self, screen):
# Right arrow
self.right_arrow = pictures.get_pygame_image(
"printer_touch.png", size, hflip=False, vflip=False, color=self._text_color)
x = int(self._rect.left + self._rect.width * 0.70
x = int(self._rect.left + self._rect.width * 0.80
Copy link
Member

Choose a reason for hiding this comment

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

Why changing this ratio?

Copy link
Author

Choose a reason for hiding this comment

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

I've changed the ratio because the text is too much positioned on the left side. I've made some tests and the users touch the text and in this case, it trigger a print instead of forgotting the photo. But even with this change, the text positionning for touchscreen are not really good. I will perhaps made some refactor of text positionning for the touchscreen version.

Copy link
Author

@lucpolak lucpolak Nov 9, 2023

Choose a reason for hiding this comment

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

The problem is for example in this case :
image
The users touch the text and trigger printing. I think I will move the text on the left side to be sure than when users touch the text, it will trigger the forgot action

Copy link
Member

@werdeil werdeil Nov 9, 2023

Choose a reason for hiding this comment

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

Unfortunately we cannot move the text to the left as the picture in portrait mode is taking the full height, that's the main reason we kept it on the right. The best workaround we gave was to update the text to be more explicit like "Appuyer sur la photo pour l'oublier" but we cannot make it default as the pibooth can be used without a touchscreen and in this case the arrow is showing which button should be pressed.

Copy link
Author

@lucpolak lucpolak Nov 10, 2023

Choose a reason for hiding this comment

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

Something like this, with the text below the left image and the printer centered
image

And in portrait mode, the image is slowly reduced to show the text below (only in touchscreen mode)
image

I've added a test if we are in portrait mode and touchscreen mode, in this case I align on top and reduce to 80% the image. What do you think about this solution ?

@@ -195,22 +196,24 @@ def paint(self, screen):

class IntroBackground(Background):

def __init__(self, arrow_location=ARROW_BOTTOM, arrow_offset=0):
def __init__(self, arrow_location=ARROW_BOTTOM, arrow_offset=0, full_width=True):
Copy link
Member

Choose a reason for hiding this comment

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

The full_width option is only used for arrow_location=ARROW_TOUCH and no print available, I guess we can find a way to avoid using a new param for that.

Copy link
Author

Choose a reason for hiding this comment

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

Ok I will try to remove the parameter

self._cam.set(cv2.CAP_PROP_ISO_SPEED, self.preview_iso)
if self.custom_fourcc != "Default":
LOGGER.info("Using custon fourcc %s", self.custom_fourcc)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
LOGGER.info("Using custon fourcc %s", self.custom_fourcc)
LOGGER.info("Using custom fourcc %s", self.custom_fourcc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants