C# Onnx segment-anything 分割萬物 一鍵摳圖

目錄

介紹

效果

模型信息

sam_vit_b_decoder.onnx

sam_vit_b_encoder.onnx

項目

代碼

下載


C# Onnx segment-anything 分割萬物 一鍵摳圖

介紹

github地址:https://github.com/facebookresearch/segment-anything

The repository provides code for running inference with the SegmentAnything Model (SAM), links for downloading the trained model checkpoints, and example notebooks that show how to use the model.?

效果

C# Onnx segment-anything 分割萬物

模型信息

sam_vit_b_decoder.onnx

Model Properties
-------------------------
---------------------------------------------------------------

Inputs
-------------------------
name:image_embeddings
tensor:Float[1, 256, 64, 64]
name:point_coords
tensor:Float[1, -1, 2]
name:point_labels
tensor:Float[1, -1]
name:mask_input
tensor:Float[1, 1, 256, 256]
name:has_mask_input
tensor:Float[1]
name:orig_im_size
tensor:Float[2]
---------------------------------------------------------------

Outputs
-------------------------
name:masks
tensor:Float[-1, -1, -1, -1]
name:iou_predictions
tensor:Float[-1, 4]
name:low_res_masks
tensor:Float[-1, -1, -1, -1]
---------------------------------------------------------------

sam_vit_b_encoder.onnx

Model Properties
-------------------------
---------------------------------------------------------------

Inputs
-------------------------
name:image
tensor:Float[1, 3, 1024, 1024]
---------------------------------------------------------------

Outputs
-------------------------
name:image_embeddings
tensor:Float[1, 256, 64, 64]
---------------------------------------------------------------

項目

代碼

using OpenCvSharp;
using OpenCvSharp.Extensions;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Reflection;
using System.Windows.Forms;

namespace Onnx_Demo
{
? ? public partial class Form1 : Form
? ? {
? ? ? ? public Form1()
? ? ? ? {
? ? ? ? ? ? InitializeComponent();
? ? ? ? }

? ? ? ? string fileFilter = "*.*|*.bmp;*.jpg;*.jpeg;*.tiff;*.tiff;*.png";
? ? ? ? string image_path = "";
? ? ? ? DateTime dt1 = DateTime.Now;
? ? ? ? DateTime dt2 = DateTime.Now;
? ? ? ? Mat image;

? ? ? ? private void button1_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? OpenFileDialog ofd = new OpenFileDialog();
? ? ? ? ? ? ofd.Filter = fileFilter;
? ? ? ? ? ? if (ofd.ShowDialog() != DialogResult.OK) return;
? ? ? ? ? ? pictureBox1.Image = null;
? ? ? ? ? ? image_path = ofd.FileName;
? ? ? ? ? ? pictureBox1.Image = new Bitmap(image_path);
? ? ? ? ? ? textBox1.Text = "";
? ? ? ? ? ? image = new Mat(image_path);
? ? ? ? ? ? pictureBox2.Image = null;
? ? ? ? ? ? pictureBox3.Image = null;

? ? ? ? ? ? sam.SetImage(image_path);
? ? ? ? ? ? image = new Mat(image_path);
? ? ? ? ? ? pictureBox1.Image = new Bitmap(image_path);
? ? ? ? }

? ? ? ? private void button2_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? pictureBox3.Image = null;
? ? ? ? ? ? button2.Enabled = false;
? ? ? ? ? ? Application.DoEvents();
? ? ? ? ? ? List<MatInfo> masks_list = sam.GetPointMask(roi);
? ? ? ? ? ? if (masks_list.Count>0)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? int MaxInde = 0;
? ? ? ? ? ? ? ? float maxiou_pred = masks_list[0].iou_pred;
? ? ? ? ? ? ? ? for (int i = 0; i < masks_list.Count; i++)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? float temp = masks_list[i].iou_pred;
? ? ? ? ? ? ? ? ? ? if (temp > maxiou_pred)
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? MaxInde = i;
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? pictureBox3.Image = BitmapConverter.ToBitmap(masks_list[MaxInde].mask);
? ? ? ? ? ? }
? ? ? ? ? ? button2.Enabled = true;
? ? ? ? }

? ? ? ? SamInferenceSession sam;

? ? ? ? private void Form1_Load(object sender, EventArgs e)
? ? ? ? {

? ? ? ? ? ? string encoderPath = "model/sam_vit_b_encoder.onnx";
? ? ? ? ? ? string decoderPath = "model/sam_vit_b_decoder.onnx";

? ? ? ? ? ? sam = new SamInferenceSession(encoderPath, decoderPath);
? ? ? ? ? ? sam.Initialize();

? ? ? ? ? ? image_path = "test_img/test.jpg";

? ? ? ? ? ? sam.SetImage(image_path);
? ? ? ? ? ? image = new Mat(image_path);
? ? ? ? ? ? pictureBox1.Image = new Bitmap(image_path);
? ? ? ? ? ??
? ? ? ? }

? ? ? ? private void pictureBox1_DoubleClick(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? Common.ShowNormalImg(pictureBox1.Image);
? ? ? ? }

? ? ? ? private void pictureBox2_DoubleClick(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? Common.ShowNormalImg(pictureBox2.Image);
? ? ? ? }

? ? ? ? SaveFileDialog sdf = new SaveFileDialog();
? ? ? ? private void button3_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? if (pictureBox2.Image == null)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? return;
? ? ? ? ? ? }
? ? ? ? ? ? Bitmap output = new Bitmap(pictureBox2.Image);
? ? ? ? ? ? sdf.Title = "保存";
? ? ? ? ? ? sdf.Filter = "Images (*.jpg)|*.jpg|Images (*.png)|*.png|Images (*.bmp)|*.bmp|Images (*.emf)|*.emf|Images (*.exif)|*.exif|Images (*.gif)|*.gif|Images (*.ico)|*.ico|Images (*.tiff)|*.tiff|Images (*.wmf)|*.wmf";
? ? ? ? ? ? if (sdf.ShowDialog() == DialogResult.OK)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? switch (sdf.FilterIndex)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? case 1:
? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? output.Save(sdf.FileName, ImageFormat.Jpeg);
? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? case 2:
? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? output.Save(sdf.FileName, ImageFormat.Png);
? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? case 3:
? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? output.Save(sdf.FileName, ImageFormat.Bmp);
? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? case 4:
? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? output.Save(sdf.FileName, ImageFormat.Emf);
? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? case 5:
? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? output.Save(sdf.FileName, ImageFormat.Exif);
? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? case 6:
? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? output.Save(sdf.FileName, ImageFormat.Gif);
? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? case 7:
? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? output.Save(sdf.FileName, ImageFormat.Icon);
? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? ? ? case 8:
? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? output.Save(sdf.FileName, ImageFormat.Tiff);
? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? case 9:
? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? output.Save(sdf.FileName, ImageFormat.Wmf);
? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? MessageBox.Show("保存成功,位置:" + sdf.FileName);
? ? ? ? ? ? }
? ? ? ? }

? ? ? ? bool m_mouseDown = false;
? ? ? ? bool m_mouseMove = false;

? ? ? ? System.Drawing.Point startPoint = new System.Drawing.Point();
? ? ? ? System.Drawing.Point endPoint = new System.Drawing.Point();

? ? ? ? Mat currentFrame = new Mat();
? ? ? ? Rect roi = new Rect();

? ? ? ? private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
? ? ? ? {
? ? ? ? ? ? if (pictureBox1.Image == null)
? ? ? ? ? ? ? ? return;
? ? ? ? ? ? if (!m_mouseDown) return;

? ? ? ? ? ? m_mouseMove = true;
? ? ? ? ? ? endPoint = e.Location;

? ? ? ? ? ? pictureBox1.Invalidate();

? ? ? ? }

? ? ? ? private void pictureBox1_Paint(object sender, PaintEventArgs e)
? ? ? ? {
? ? ? ? ? ? if (!m_mouseDown || !m_mouseMove)
? ? ? ? ? ? ? ? return;
? ? ? ? ? ? Graphics g = e.Graphics;
? ? ? ? ? ? Pen p = new Pen(Color.Blue, 2);
? ? ? ? ? ? Rectangle rect = new Rectangle(startPoint.X, startPoint.Y, (endPoint.X - startPoint.X), (endPoint.Y - startPoint.Y));
? ? ? ? ? ? g.DrawRectangle(p, rect);

? ? ? ? }

? ? ? ? private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
? ? ? ? {
? ? ? ? ? ? if (!m_mouseDown || !m_mouseMove)
? ? ? ? ? ? ? ? return;
? ? ? ? ? ? m_mouseDown = false;
? ? ? ? ? ? m_mouseMove = false;

? ? ? ? ? ? System.Drawing.Point image_startPoint = ConvertCooridinate(startPoint);
? ? ? ? ? ? System.Drawing.Point image_endPoint = ConvertCooridinate(endPoint);
? ? ? ? ? ? if (image_startPoint.X < 0)
? ? ? ? ? ? ? ? image_startPoint.X = 0;
? ? ? ? ? ? if (image_startPoint.Y < 0)
? ? ? ? ? ? ? ? image_startPoint.Y = 0;
? ? ? ? ? ? if (image_endPoint.X < 0)
? ? ? ? ? ? ? ? image_endPoint.X = 0;
? ? ? ? ? ? if (image_endPoint.Y < 0)
? ? ? ? ? ? ? ? image_endPoint.Y = 0;
? ? ? ? ? ? if (image_startPoint.X > image.Cols)
? ? ? ? ? ? ? ? image_startPoint.X = image.Cols;
? ? ? ? ? ? if (image_startPoint.Y > image.Rows)
? ? ? ? ? ? ? ? image_startPoint.Y = image.Rows;
? ? ? ? ? ? if (image_endPoint.X > image.Cols)
? ? ? ? ? ? ? ? image_endPoint.X = image.Cols;
? ? ? ? ? ? if (image_endPoint.Y > image.Rows)
? ? ? ? ? ? ? ? image_endPoint.Y = image.Rows;

? ? ? ? ? ? label1.Text = String.Format("ROI:({0},{1})-({2},{3})", image_startPoint.X, image_startPoint.Y, image_endPoint.X, image_endPoint.Y);
? ? ? ? ? ? int w = (image_endPoint.X - image_startPoint.X);
? ? ? ? ? ? int h = (image_endPoint.Y - image_startPoint.Y);
? ? ? ? ? ? if (w > 10 && h > 10)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? roi = new Rect(image_startPoint.X, image_startPoint.Y, w, h);
? ? ? ? ? ? ? ? //Console.WriteLine(String.Format("ROI:({0},{1})-({2},{3})", image_startPoint.X, image_startPoint.Y, image_endPoint.X, image_endPoint.Y));
? ? ? ? ? ? ? ? //test
? ? ? ? ? ? ? ? //OpenCvSharp.Point pointinfo = new OpenCvSharp.Point(910, 641);
? ? ? ? ? ? ? ? //roi = new Rect(pointinfo.X - 160, pointinfo.Y - 430, 380, 940);
? ? ? ? ? ? ? ? Mat roi_mat = image[roi];
? ? ? ? ? ? ? ? pictureBox2.Image = BitmapConverter.ToBitmap(roi_mat);
? ? ? ? ? ? }
? ? ? ? ? ? //pictureBox1.Invalidate();

? ? ? ? }

? ? ? ? private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
? ? ? ? {
? ? ? ? ? ? if (pictureBox1.Image == null)
? ? ? ? ? ? ? ? return;
? ? ? ? ? ? m_mouseDown = true;
? ? ? ? ? ? startPoint = e.Location;
? ? ? ? }

? ? ? ? private System.Drawing.Point ConvertCooridinate(System.Drawing.Point point)
? ? ? ? {
? ? ? ? ? ? System.Reflection.PropertyInfo rectangleProperty = this.pictureBox1.GetType().GetProperty("ImageRectangle", BindingFlags.Instance | BindingFlags.NonPublic);
? ? ? ? ? ? Rectangle pictureBox = (Rectangle)rectangleProperty.GetValue(this.pictureBox1, null);

? ? ? ? ? ? int zoomedWidth = pictureBox.Width;
? ? ? ? ? ? int zoomedHeight = pictureBox.Height;

? ? ? ? ? ? int imageWidth = pictureBox1.Image.Width;
? ? ? ? ? ? int imageHeight = pictureBox1.Image.Height;

? ? ? ? ? ? double zoomRatex = (double)(zoomedWidth) / (double)(imageWidth);
? ? ? ? ? ? double zoomRatey = (double)(zoomedHeight) / (double)(imageHeight);
? ? ? ? ? ? int black_left_width = (zoomedWidth == this.pictureBox1.Width) ? 0 : (this.pictureBox1.Width - zoomedWidth) / 2;
? ? ? ? ? ? int black_top_height = (zoomedHeight == this.pictureBox1.Height) ? 0 : (this.pictureBox1.Height - zoomedHeight) / 2;

? ? ? ? ? ? int zoomedX = point.X - black_left_width;
? ? ? ? ? ? int zoomedY = point.Y - black_top_height;

? ? ? ? ? ? System.Drawing.Point outPoint = new System.Drawing.Point();
? ? ? ? ? ? outPoint.X = (int)((double)zoomedX / zoomRatex);
? ? ? ? ? ? outPoint.Y = (int)((double)zoomedY / zoomRatey);

? ? ? ? ? ? return outPoint;
? ? ? ? }

? ? }
}

using OpenCvSharp;
using OpenCvSharp.Extensions;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Reflection;
using System.Windows.Forms;namespace Onnx_Demo
{public partial class Form1 : Form{public Form1(){InitializeComponent();}string fileFilter = "*.*|*.bmp;*.jpg;*.jpeg;*.tiff;*.tiff;*.png";string image_path = "";DateTime dt1 = DateTime.Now;DateTime dt2 = DateTime.Now;Mat image;private void button1_Click(object sender, EventArgs e){OpenFileDialog ofd = new OpenFileDialog();ofd.Filter = fileFilter;if (ofd.ShowDialog() != DialogResult.OK) return;pictureBox1.Image = null;image_path = ofd.FileName;pictureBox1.Image = new Bitmap(image_path);textBox1.Text = "";image = new Mat(image_path);pictureBox2.Image = null;pictureBox3.Image = null;sam.SetImage(image_path);image = new Mat(image_path);pictureBox1.Image = new Bitmap(image_path);}private void button2_Click(object sender, EventArgs e){pictureBox3.Image = null;button2.Enabled = false;Application.DoEvents();List<MatInfo> masks_list = sam.GetPointMask(roi);if (masks_list.Count>0){int MaxInde = 0;float maxiou_pred = masks_list[0].iou_pred;for (int i = 0; i < masks_list.Count; i++){float temp = masks_list[i].iou_pred;if (temp > maxiou_pred){MaxInde = i;}}pictureBox3.Image = BitmapConverter.ToBitmap(masks_list[MaxInde].mask);}button2.Enabled = true;}SamInferenceSession sam;private void Form1_Load(object sender, EventArgs e){string encoderPath = "model/sam_vit_b_encoder.onnx";string decoderPath = "model/sam_vit_b_decoder.onnx";sam = new SamInferenceSession(encoderPath, decoderPath);sam.Initialize();image_path = "test_img/test.jpg";sam.SetImage(image_path);image = new Mat(image_path);pictureBox1.Image = new Bitmap(image_path);}private void pictureBox1_DoubleClick(object sender, EventArgs e){Common.ShowNormalImg(pictureBox1.Image);}private void pictureBox2_DoubleClick(object sender, EventArgs e){Common.ShowNormalImg(pictureBox2.Image);}SaveFileDialog sdf = new SaveFileDialog();private void button3_Click(object sender, EventArgs e){if (pictureBox2.Image == null){return;}Bitmap output = new Bitmap(pictureBox2.Image);sdf.Title = "保存";sdf.Filter = "Images (*.jpg)|*.jpg|Images (*.png)|*.png|Images (*.bmp)|*.bmp|Images (*.emf)|*.emf|Images (*.exif)|*.exif|Images (*.gif)|*.gif|Images (*.ico)|*.ico|Images (*.tiff)|*.tiff|Images (*.wmf)|*.wmf";if (sdf.ShowDialog() == DialogResult.OK){switch (sdf.FilterIndex){case 1:{output.Save(sdf.FileName, ImageFormat.Jpeg);break;}case 2:{output.Save(sdf.FileName, ImageFormat.Png);break;}case 3:{output.Save(sdf.FileName, ImageFormat.Bmp);break;}case 4:{output.Save(sdf.FileName, ImageFormat.Emf);break;}case 5:{output.Save(sdf.FileName, ImageFormat.Exif);break;}case 6:{output.Save(sdf.FileName, ImageFormat.Gif);break;}case 7:{output.Save(sdf.FileName, ImageFormat.Icon);break;}case 8:{output.Save(sdf.FileName, ImageFormat.Tiff);break;}case 9:{output.Save(sdf.FileName, ImageFormat.Wmf);break;}}MessageBox.Show("保存成功,位置:" + sdf.FileName);}}bool m_mouseDown = false;bool m_mouseMove = false;System.Drawing.Point startPoint = new System.Drawing.Point();System.Drawing.Point endPoint = new System.Drawing.Point();Mat currentFrame = new Mat();Rect roi = new Rect();private void pictureBox1_MouseMove(object sender, MouseEventArgs e){if (pictureBox1.Image == null)return;if (!m_mouseDown) return;m_mouseMove = true;endPoint = e.Location;pictureBox1.Invalidate();}private void pictureBox1_Paint(object sender, PaintEventArgs e){if (!m_mouseDown || !m_mouseMove)return;Graphics g = e.Graphics;Pen p = new Pen(Color.Blue, 2);Rectangle rect = new Rectangle(startPoint.X, startPoint.Y, (endPoint.X - startPoint.X), (endPoint.Y - startPoint.Y));g.DrawRectangle(p, rect);}private void pictureBox1_MouseUp(object sender, MouseEventArgs e){if (!m_mouseDown || !m_mouseMove)return;m_mouseDown = false;m_mouseMove = false;System.Drawing.Point image_startPoint = ConvertCooridinate(startPoint);System.Drawing.Point image_endPoint = ConvertCooridinate(endPoint);if (image_startPoint.X < 0)image_startPoint.X = 0;if (image_startPoint.Y < 0)image_startPoint.Y = 0;if (image_endPoint.X < 0)image_endPoint.X = 0;if (image_endPoint.Y < 0)image_endPoint.Y = 0;if (image_startPoint.X > image.Cols)image_startPoint.X = image.Cols;if (image_startPoint.Y > image.Rows)image_startPoint.Y = image.Rows;if (image_endPoint.X > image.Cols)image_endPoint.X = image.Cols;if (image_endPoint.Y > image.Rows)image_endPoint.Y = image.Rows;label1.Text = String.Format("ROI:({0},{1})-({2},{3})", image_startPoint.X, image_startPoint.Y, image_endPoint.X, image_endPoint.Y);int w = (image_endPoint.X - image_startPoint.X);int h = (image_endPoint.Y - image_startPoint.Y);if (w > 10 && h > 10){roi = new Rect(image_startPoint.X, image_startPoint.Y, w, h);//Console.WriteLine(String.Format("ROI:({0},{1})-({2},{3})", image_startPoint.X, image_startPoint.Y, image_endPoint.X, image_endPoint.Y));//test//OpenCvSharp.Point pointinfo = new OpenCvSharp.Point(910, 641);//roi = new Rect(pointinfo.X - 160, pointinfo.Y - 430, 380, 940);Mat roi_mat = image[roi];pictureBox2.Image = BitmapConverter.ToBitmap(roi_mat);}//pictureBox1.Invalidate();}private void pictureBox1_MouseDown(object sender, MouseEventArgs e){if (pictureBox1.Image == null)return;m_mouseDown = true;startPoint = e.Location;}private System.Drawing.Point ConvertCooridinate(System.Drawing.Point point){System.Reflection.PropertyInfo rectangleProperty = this.pictureBox1.GetType().GetProperty("ImageRectangle", BindingFlags.Instance | BindingFlags.NonPublic);Rectangle pictureBox = (Rectangle)rectangleProperty.GetValue(this.pictureBox1, null);int zoomedWidth = pictureBox.Width;int zoomedHeight = pictureBox.Height;int imageWidth = pictureBox1.Image.Width;int imageHeight = pictureBox1.Image.Height;double zoomRatex = (double)(zoomedWidth) / (double)(imageWidth);double zoomRatey = (double)(zoomedHeight) / (double)(imageHeight);int black_left_width = (zoomedWidth == this.pictureBox1.Width) ? 0 : (this.pictureBox1.Width - zoomedWidth) / 2;int black_top_height = (zoomedHeight == this.pictureBox1.Height) ? 0 : (this.pictureBox1.Height - zoomedHeight) / 2;int zoomedX = point.X - black_left_width;int zoomedY = point.Y - black_top_height;System.Drawing.Point outPoint = new System.Drawing.Point();outPoint.X = (int)((double)zoomedX / zoomRatex);outPoint.Y = (int)((double)zoomedY / zoomRatey);return outPoint;}}
}

下載

源碼下載


?

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/719200.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/719200.shtml
英文地址,請注明出處:http://en.pswp.cn/news/719200.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

設計模式(十二)享元模式

請直接看原文: 原文鏈接:設計模式&#xff08;十二&#xff09;享元模式-CSDN博客 -------------------------------------------------------------------------------------------------------------------------------- 享元模式定義 享元模式是結構型設計模式的一種&am…

Kubernetes-1

學習Kubernetes第一天 k8s-11、什么是Kubernetes2、配置Kubernetes2.1、準備三臺全新的虛擬機2.2、關閉防火墻和SElinux2.3、修改主機名2.4、升級操作系統(三臺一起操作)2.5、配置主機hosts文件&#xff0c;相互之間通過主機名互相訪問2.6、配置master和node之間的免密通道2.7、…

KMP算法和Manacher算法

KMP算法 KMP算法解決的問題 KMP算法用來解決字符串匹配問題: 找到長串中短串出現的位置. KMP算法思路 暴力比較與KMP的區別 暴力匹配: 對長串的每個位,都從頭開始匹配短串的所有位. KMP算法: 將短字符串前后相同的部分存儲在 n e x t next next數組里,讓之前匹配過的信息指…

我的單片機入門之旅

我的單片機入門之旅 前言 單片機作為現代電子技術的重要組成部分&#xff0c;廣泛應用于各個領域。而作為一個初學者&#xff0c;我對單片機一無所知。但是&#xff0c;通過不斷的學習和實踐&#xff0c;我逐漸掌握了單片機的基本概念和使用方法。在我的單片機入門之旅中&…

【每日前端面經】2024-03-03

題目來源: 牛客 說說你對Vue3的理解&#xff1f; Vue2面對對象編程&#xff0c;Vue3函數時編程對TS支持的更好選項式API替代組合式API響應式原理由Object.defineProperty變為Proxy支持template中存在多個根節點重寫虛擬DOM增加setup修飾符支持tree-shaking&#xff0c;減小體…

代碼隨想錄算法訓練營(動態規劃10,11 股票問題)| 121. 買賣股票的最佳時機 122.買賣股票的最佳時機II

動態規劃10 動態規劃5步曲&#xff0c;個人感覺應該加一步狀態分析 狀態分析&#xff1a; 列出所有的狀態&#xff0c;將狀態歸納后定義dp數組狀態轉移&#xff0c;狀態怎么轉移也就是遞推公式是什么 買賣股票的動規五部曲分析如下&#xff1a; 1 確定dp數組&#xff08;d…

pytorch中的可學習查找表實現之nn.Embedding

假設我們需要一個查找表&#xff08;Lookup Table&#xff09;&#xff0c;我們可以根據索引數字快速定位查找表中某個具體位置并讀取出來。最簡單的方法&#xff0c;可以通過一個二維數組或者二維list來實現。但如果我希望查找表的值可以通過梯度反向傳播來修改&#xff0c;那…

上傳項目的全部依賴到maven私有倉庫-nexus

背景 項目之前的私有倉庫不能使用了&#xff0c;本地倉庫可以&#xff0c;但是一旦clean就沒了&#xff0c;所以在本地有依賴的時候可以自己搭建一個maven私有倉庫然后將依賴全部上傳上去 搭建&#xff1a;使用docker-compose方式搭建 docker-compose文件 version: "3…

C語言入門到精通之練習47:一個偶數總能表示為兩個素數之和。

題目&#xff1a;一個偶數總能表示為兩個素數之和。 程序分析&#xff1a;我去&#xff0c;這是什么題目&#xff0c;要我證明這個問題嗎&#xff1f;真不知道怎么證明。那就把一個偶數串聯成兩個素數吧。 實例 #include<stdio.h> #include<stdlib.h> int Isprime…

Python算法100例-3.1 回文數

完整源代碼項目地址&#xff0c;關注博主私信源代碼后可獲取 1.問題描述2.問題分析3.算法設計4.確定程序框架5.完整的程序6.問題拓展7.巧用字符串技巧 1&#xff0e;問題描述 打印所有不超過n&#xff08;取n<256&#xff09;的其平方具有對稱性質的數&#xff08;也稱回…

在國內如何申請US,visa卡?

隨著跨境與AI的發展大家對美國虛擬卡的需求也越來越多&#xff0c;比如說亞馬遜、ebay、Etsy、ChatGPTPLUS、midjourney、POE等等軟件以及海淘的需要&#xff0c;所以我們需要用到美國虛擬卡的場景就越來越多 如何獲得一張US 虛擬信用卡&#xff1f; 方法很簡單&#xff0c;點…

一線大廠軟件測試面試題及答案解析,2024最強版...

【軟件測試面試突擊班】2024吃透軟件測試面試最全八股文攻略教程&#xff0c;一周學完讓你面試通過率提高90%&#xff01;&#xff08;自動化測試&#xff09; 1、什么是兼容性測試?兼容性測試側重哪些方面? 參考答案: 兼容測試主要是檢查軟件在不同的硬件平臺、軟件平臺上…

CNAN知識圖譜輔助推薦系統

CNAN知識圖譜輔助推薦系統 文章介紹了一個基于KG的推薦系統模型&#xff0c;代碼也已開源&#xff0c;可以看出主要follow了KGNN-LS 。算法流程大致如下&#xff1a; 1. 算法介紹 算法除去attention機制外&#xff0c;主要的思想在于&#xff1a;user由交互過的item來表示、i…

OpenShift AI - 部署并使用 LLM 模型

《OpenShift / RHEL / DevSecOps 匯總目錄》 說明&#xff1a;本文已經在 OpenShift 4.15 RHODS 2.7.0 的環境中驗證 文章目錄 安裝 OpenShift AI 環境安裝 Minio 對象存儲軟件配置 Single Model Serving 運行環境創建項目和 Workbench準備模型和配置 Model Server訪問 LLM 模…

arm-linux-gnueabi、arm-linux-gnueabihf 交叉編譯器區別

1、arm-linux-gnueabi&#xff1a; 使用軟件浮點&#xff08;軟浮點&#xff09;。這意味著所有的浮點運算都將由軟件庫來處理&#xff0c;而不會利用硬件中的浮點運算單元。因此&#xff0c;生成的目標代碼包含了對軟件浮點庫的調用。 2、arm-linux-gnueabihf&#xff1a; 使…

c++八股文:c++新特性

文章目錄 [toc] 1.C11的新特性有哪些2.智能指針3.類型推導4.左值和右值5.nullptr6.范圍for循環7.lambda表達式參考 1.C11的新特性有哪些 語法的改進 &#xff08;1&#xff09;統?的初始化?法 &#xff08;2&#xff09;成員變量默認初始化 &#xff08;3&#xff09;auto關…

mybatis中#{}和${}的區別?

#{}是占位符&#xff0c;預編譯處理&#xff1b;${}是拼接符&#xff0c;字符串替換&#xff0c;沒有預編譯處理。 Mybatis在處理#{}時&#xff0c;#{}傳入參數是以字符串傳入&#xff0c;會將SQL中的#{}替換為?號&#xff0c;調用PreparedStatement的set方法來賦值。 Mybat…

DCTNet

DCTNet http://giantpandacv.com/academic/%E7%AE%97%E6%B3%95%E7%A7%91%E6%99%AE/%E9%A2%91%E5%9F%9F%E4%B8%AD%E7%9A%84CNN/CVPR%202020%20%E5%9C%A8%E9%A2%91%E5%9F%9F%E4%B8%AD%E5%AD%A6%E4%B9%A0%E7%9A%84DCTNet/ 一個對輸入圖像進行頻域轉換和選擇的方法&#xff0c;達到…

python實現手機號歸屬地查詢

手機上突然收到了某銀行的短信提示&#xff0c;看了一下手機的位數&#xff0c;正好是11位。我一想&#xff0c;這不就是標準的手機號碼嗎&#xff1f;于是一個想法涌上心頭——用python的庫實現查詢手機號碼歸屬地查詢自由。 那實現的效果如下&#xff1a; 注&#xff1a;電…

達夢數據庫基礎操作(一):用戶操作

達夢數據庫基礎操作(一)&#xff1a;用戶操作 1 達夢運行狀態 SELECT banner as 版本信息 FROM v$version;1.2 達夢版本號 SELECT banner as 版本信息 FROM v$version;1.3 用戶相關操作 默認用戶名密碼&#xff1a;SYSDBA/SYSDBA 注意&#xff1a;在哪個數據庫下創建的用戶…