spring98 / flutter-yolo-realtime-plugin

실시간 객체검출 플러그인 배포 (2023)
MIT License
7 stars 4 forks source link

how to modify it to landescape orientation? #8

Open MyriamIhab opened 5 months ago

MyriamIhab commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

I'm really glad it helped.

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

fransay commented 2 months ago

@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 commented 2 months ago

@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 :-)