How to make an detection box with AI that works [closed]

I have tried to make an AI detection box with using Onnx where i want to make it so if i am in vs2022 and make the application i want to make it so if i check a checkbox it will activate the AI and will capture my screen in real time and it works but the problem i am having is that the AI boxes always show up on the left side of my screen and i do not really know why it can be because i am using 640 x 640 but as i see it it should be in the middle and not up to the left, idk it is hard to explain but if someone needs more explaining i can do that, here is some of the code that i have now for these stuff:

private void DetectItems(Bitmap screen)
        {
            var inputTensor = PreprocessImage(screen, 640, 640);
            var input = new List<NamedOnnxValue> { NamedOnnxValue.CreateFromTensor("images", inputTensor) };

            List<DetectedItem> detectedItems;

            using (var results = session.Run(input))
            {
                detectedItems = ParseYoloOutput(results);
            }

            // Draw bounding boxes directly on the screen (overlay)
            using (Graphics g = Graphics.FromHwnd(IntPtr.Zero)) // Drawing on the screen
            {
                foreach (var item in detectedItems)
                {
                    g.DrawRectangle(Pens.Red, item.Box);
                    string detectedClassName = GetClassNameFromId(item.ClassId);
                    g.DrawString($"{detectedClassName} ({item.Confidence:P0})", new Font("Arial", 16), Brushes.Red, item.Box.X, item.Box.Y);
                }
            }
        }

private List<DetectedItem> ParseYoloOutput(IDisposableReadOnlyCollection<DisposableNamedOnnxValue> results)
        {
            var output = results.First().AsEnumerable<float>().ToArray();
            List<DetectedItem> detectedItems = new List<DetectedItem>();

            for (int i = 0; i < output.Length; i += 6)
            {
                float x = output[i] * Screen.PrimaryScreen.Bounds.Width;
                float y = output[i + 1] * Screen.PrimaryScreen.Bounds.Height;
                float width = output[i + 2] * Screen.PrimaryScreen.Bounds.Width;
                float height = output[i + 3] * Screen.PrimaryScreen.Bounds.Height;
                float confidence = output[i + 4];
                int classId = (int)output[i + 5];

                if (confidence > 0.1f)
                {
                    DetectedItem item = new DetectedItem
                    {
                        Box = new Rectangle((int)x, (int)y, (int)width, (int)height),
                        ClassId = classId,
                        Confidence = confidence
                    };

                    detectedItems.Add(item);
                }
            }

            return detectedItems;
        }

        private Tensor<float> PreprocessImage(Bitmap bitmap, int width, int height)
        {
            Bitmap resized = new Bitmap(bitmap, new Size(width, height));
            var input = new DenseTensor<float>(new[] { 1, 2, height, width });

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    Color pixel = resized.GetPixel(x, y);
                    input[0, 0, y, x] = pixel.R / 255f;
                    input[0, 1, y, x] = pixel.G / 255f;
                    input[0, 2, y, x] = pixel.B / 255f;
                }
            }

            return input;
        }

        private void checkBoxEnableAI_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBoxEnableAI.Checked)
            {
                if (detectionTimer == null)
                {
                    detectionTimer = new Timer();
                    detectionTimer.Interval = 1000; // Detect every second
                    detectionTimer.Tick += (s, ev) =>
                    {
                        Bitmap screenshot = CaptureScreen();
                        DetectItems(screenshot);  // Run detection and draw bounding boxes
                    };
                }
                detectionTimer.Start();
            }
            else
            {
                detectionTimer?.Stop();
            }
        }


i tried to chance it so i had like an FOV in the middle of my screen that was like an 640 x 640 and it was always visible from the start of starting the menu and in the fov is where the AI will be active everything outside of the fov will make the AI not detect the object like a banana or something but i could not make the fov be in the middle of my screen while making the AI only target everything inside of it because i am not the best in C# got some help from chatgpt but that it not work so i am here now needing some tips

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật