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

how to modify it to landescape orientation? #8

Open
MyriamIhab opened this issue Apr 3, 2024 · 5 comments
Open

how to modify it to landescape orientation? #8

MyriamIhab opened this issue Apr 3, 2024 · 5 comments

Comments

@MyriamIhab
Copy link

When portrait orientation is used the boxes are drawn correctly around the detceted object (of cource while holding the mobile horizontally like the example's video), but when I enforce lanescape orientation to the page boxes are drawn beside the objects (not around them) and their length and width are inverted. How can this be adjusted?
cupdetection

@spring98
Copy link
Owner

spring98 commented Apr 4, 2024

hello!
Thank you for using my plugin.

This problem occurs because the plug-in was created to be used as in the example video.

To solve this problem

  1. drawBox: false;
  2. Invert the Rect value of BoxModel received from captureBox
  3. Draw the inverted Rect again with paint

It must be quite a cumbersome task.
sorry. It's my fault.

We will add an orientation option as time allows.

@MyriamIhab
Copy link
Author

MyriamIhab commented Apr 4, 2024

I don't understand how to implement the solution as you suggested. However, I managed to resolve the issue by adjusting some parameters in the "YoloRealTimeView" widget class (in the "yolo_realtime_view.dart" file), and it now works correctly in landscape orientation. Here are the updated parameters:

          final rectX = x * screenWidth;
          final rectY = screenHeight - ((y + height) * screenHeight);
          final rectWidth = width * screenWidth;
          final rectHeight = height * screenHeight;

You may consider incorporating these changes into future versions of the package to support landscape orientation effectively. I appreciate the package's functionality; it has been incredibly helpful. Thank you.

@spring98
Copy link
Owner

spring98 commented Apr 4, 2024

I'm really glad it helped.

I will use the code you suggested in the next modification.
thank you!!

@fransay
Copy link

fransay commented Jun 20, 2024

@spring98 I found your wonderful plugin in the early hours of today, cloned the example app, tested and it works fine. I have been struggling to get a decent package like yours that support both ios and android. tflite_flutter simply doesn't work for me and everything around model ingestion is a pain in the butt. Though, I have not yet tested this awesome implementation of yours on my custom model, I want to simply send out my thank you note and good wishes for taking time to work on this. You a gem!

@fransay
Copy link

fransay commented Jun 20, 2024

@MyriamIhab thanks for sharing your improvement, with a little conditional statements and the magic of mediaQuery.of.(context).orientatation. We can correctly draw the boxes based on the orientation of the devices. I have not yet tested your implementation, but I know for sure, its going to be a good one. Thanks for sharing friend :-)

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

No branches or pull requests

3 participants