POSE拼图开发解析(更新中)

1002版源代码http://vdisk.weibo.com/s/3PofL


一、概要设计

把程序分为3个主要模块,设计模块,拍照模块,拼接模块和一个额外的自动更新模块。

【设计模块】

主要的想法是把工具区的每个图形标上号,对应于显示在右边设计区的图形,姿势图片和覆盖在摄像头视频上的虚线框以及拍下的照片。

将设计区的图案按照标号转化为一个数组传到拍照模块。

【拍照模块】

接收到设计模块传来的设计数组,按照标号顺序进行检索,检索到存在该姿势,便进行拍照,把拍下的照片存在另一个数组中。

【拼接模块】

遍历设计模块的数组,更根据数组值去检索拍照模块拍出的照片。

额外的【自动更新模块】

在执行功能前打开自动更新程序,自动更新程序连接到服务器检查最新的版本,与客户端版本进行比较,如果客户端版本低于服务器上的版本,结束原有主程序,从服务器下载更新包(用自解压包装),下载完成后运行更新包,更新包自解压将原有老版本程序覆盖,更新完毕后会自动删除更新包自身。


二、详细设计

【设计模块】

设计模块主要用了GDI编程,利用各种GDI函数在PANEL控件上作画

private readonly int _iconNum = 17;
        private readonly int _row = 9;
        private readonly int _col = 2;
        public int _imagerow = 5;
        public int _imagecol = 6;
        private readonly int _iconSize = 30;
        private readonly int _imageSize = 50;
        private PictureBox[,] _iconPictureBox;
        private PictureBox[,] _imagePictureBox;
        private int _pastX;
        private int _pastY;
        private int _selectedX = 0;
        private int _selectedY = 0;
        private int _selectedNum = 0;
        static public int[] _imageList;
        private StartFrom _startFrm;
        private PrepareForm _prepareFrm;
        System.Resources.ResourceManager _resources = new System.Resources.ResourceManager("主界面.Resource1",
            Assembly.GetExecutingAssembly());


        public DesignForm(StartFrom frm)
        {
            InitializeComponent();
            _startFrm = frm;
            this._iconPictureBox = new PictureBox[this._row, this._col];
        }
重载了默认的构造函数,把开始界面的窗口作为参数传到设计窗口,避免了常用的新建窗口然后用hide和 show方法导致后台打开过多窗口。


        public DesignForm(PrepareForm frm)
        {
            InitializeComponent();
            _prepareFrm = frm;
            this._iconPictureBox = new PictureBox[this._row, this._col];
        }
        private void design_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }


        private void IconPnl_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            g.FillRectangle(Brushes.WhiteSmoke, new Rectangle(0, 0, this.IconPnl.Width,
                this.IconPnl.Height));
            int index = 0;
            for (int yPos = 0; yPos < this._row; yPos++)
            {
                for (int xPos = 0; xPos < this._col; xPos++)
                {
                    if (index == this._iconNum)
                        break;
                    Image Image = (Image)this._resources.GetObject("_" + index);
                    this._iconPictureBox[yPos, xPos] = new PictureBox();
                    this._iconPictureBox[yPos, xPos].Image = Image;
                    g.DrawImage(Image, xPos * 31 + 1, yPos * 31 + 1, this._iconSize, this._iconSize);
                    // g.DrawRectangle(new Pen(Color.BlueViolet), new Rectangle(xPos*31, yPos*31, Image.Width+1, Image.Height+1));
                    drawFrame(g);
                    index++;
                }
            }
        }

在工具区画出16中线条以及橡皮擦工具
        private void drawFrame(Graphics g)//画框
        {
            for (int yPos = 0; yPos < this._row; yPos++)
            {
                for (int xPos = 0; xPos < this._col; xPos++)
                {
                    if (this._iconPictureBox[yPos, xPos] != null)
                        g.DrawRectangle(new Pen(Color.BlueViolet), new Rectangle(xPos * 31, yPos * 31, 31, 31));
                }
            }
            drawSelectedFrame(g);//画选择的框
        }
        private void drawSelectedFrame(Graphics g)//画出选择的红线
        {
            if (this._iconPictureBox[_selectedY, _selectedX] != null)
                g.DrawRectangle(new Pen(Color.Red), new Rectangle(_selectedX * 31, _selectedY * 31, 30 + 1, 30 + 1));
        }


        private void IconPnl_MouseMove(object sender, MouseEventArgs e)
        {
            Graphics g = IconPnl.CreateGraphics();
            int xPos = e.X / 31;
            int yPos = e.Y / 31;
            if (_pastX == xPos && _pastY == yPos)
                return;
            //             if (_selectedX == xPos && _selectedY == yPos)
            //                 drawFrame(g);
            _pastX = xPos;
            _pastY = yPos;
            if (yPos < this._row && xPos < this._col)
            {
                if (this._iconPictureBox[yPos, xPos] != null)
                {
                    drawFrame(g);
                    if (_selectedX != xPos || _selectedY != yPos)//不是已经选择的才有黑框
                        g.DrawRectangle(new Pen(Color.Black), new Rectangle(xPos * 31, yPos * 31, 30 + 1, 30 + 1));
                }
            }
        }


        private void IconPnl_MouseLeave(object sender, EventArgs e)
        {
            Graphics g = IconPnl.CreateGraphics();//重新画框
            drawFrame(g);
        }


        private void IconPnl_MouseDown(object sender, MouseEventArgs e)
        {
            Graphics g = IconPnl.CreateGraphics();
            int xPos = e.X / 31;
            int yPos = e.Y / 31;
            _selectedX = xPos;
            _selectedY = yPos;
            if (yPos < this._row && xPos < this._col)
            {
                if (this._iconPictureBox[yPos, xPos] != null)
                {
                    drawFrame(g);
                    _selectedNum = yPos * 2 + xPos;
                    //MessageBox.Show(_selectedNum.ToString());
                    // g.DrawRectangle(new Pen(Color.Red), new Rectangle(xPos * 31, yPos * 31, 30 + 1, 30 + 1));
                }
            }
        }


        private void DrawImagePanel(Graphics g)
        {
            //int index = 0;
            g.FillRectangle(Brushes.WhiteSmoke, new Rectangle(0, 0, this.ImagePnl.Width,
                this.ImagePnl.Height));
            this._imagePictureBox = new PictureBox[this._imagerow, this._imagecol];
            for (int yPos = 0; yPos < this._imagerow; yPos++)
            {
                for (int xPos = 0; xPos < this._imagecol; xPos++)
                {
                    Image image = (Image)this._resources.GetObject("i" + _imageList[yPos * _imagecol + xPos]);
                    this._imagePictureBox[yPos, xPos] = new PictureBox();
                    this._imagePictureBox[yPos, xPos].Image = image;
                    g.DrawImage(image, xPos * 52 + 2, yPos * 52 + 2, this._imageSize, this._imageSize);
                }
            }
            DrawImageFrame(g);
        }


        private void DrawImageFrame(Graphics g)
        {
            for (int yPos = 0; yPos < _imagerow; yPos++)
            {
                for (int xPos = 0; xPos < _imagecol; xPos++)
                {
                    g.DrawRectangle(new Pen(Color.BlueViolet, 2), new Rectangle(xPos * 52 + 1, yPos * 52 + 1, 52, 52));
                }
            }
        }


        private void Design_HeartButton_Click(object sender, EventArgs e)
        {
            this._imagerow = 5;
            this._imagecol = 6;
            ImagePnl.Size = new System.Drawing.Size(52 * this._imagecol + 2, 52 * this._imagerow + 2);
            _imageList = new int[] { 16,10,14,15, 8,16, 
                                   11,16,13,12,16, 7, 
                                    9,16,16,16,16, 5, 
                                   16, 2,16,16, 3,16,
                                   16,16, 2, 3,16,16};
            Graphics g = ImagePnl.CreateGraphics();
            DrawImagePanel(g);
        }


        private void ImagePnl_MouseClick(object sender, MouseEventArgs e)
        {
            Graphics g = ImagePnl.CreateGraphics();
            int xPos = e.X / 52;
            int yPos = e.Y / 52;
            if (yPos < this._imagerow && xPos < this._imagecol)
            {
                _imageList[yPos * this._imagecol + xPos] = _selectedNum;
                //清空
                Image image = (Image)this._resources.GetObject("i" + 16);
                //this._imagePictureBox[yPos, xPos].Image = image;
                g.DrawImage(image, xPos * 52 + 2, yPos * 52 + 2, this._imageSize, this._imageSize);
                //绘图
                Image image2 = (Image)this._resources.GetObject("i" + _imageList[yPos * _imagecol + xPos]);
                this._imagePictureBox[yPos, xPos].Image = image;
                g.DrawImage(image2, xPos * 52 + 2, yPos * 52 + 2, this._imageSize, this._imageSize);
            }
        }


        private void Design_ILoveUButton_Click(object sender, EventArgs e)
        {
            this._imagerow = 6;
            this._imagecol = 8;
            ImagePnl.Size = new System.Drawing.Size(52 * this._imagecol + 2, 52 * this._imagerow + 2);
            _imageList = new int[] { 16,16,16,16,16,16,16,16,
                                    1,11, 2, 3, 7, 1,16, 1,
                                    1, 5,16,16, 9, 1,16, 1,
                                    1, 2,16,16, 3, 1,16, 1,
                                    1,16, 2, 3,16,13, 0,12,
                                    16,16,16,16,16,16,16,16};
            Graphics g = ImagePnl.CreateGraphics();
            DrawImagePanel(g);
        }




        private void Design_ChristsmasTreeButton_Click(object sender, EventArgs e)
        {
            this._imagerow = 6;
            this._imagecol = 4;
            ImagePnl.Size = new System.Drawing.Size(52 * this._imagecol + 2, 52 * this._imagerow + 2);
            _imageList = new int[] { 16, 3, 2,16,
                                   16, 5, 9,16,
                                   11,16,16, 7,
                                    3,16,16, 2,
                                   16, 1, 1,16,
                                   16, 1, 1,16};
            Graphics g = ImagePnl.CreateGraphics();
            DrawImagePanel(g);
        }


        private void Design_UmbrellaButton_Click(object sender, EventArgs e)
        {
            this._imagerow = 6;
            this._imagecol = 5;
            ImagePnl.Size = new System.Drawing.Size(52 * this._imagecol + 2, 52 * this._imagerow + 2);
            _imageList = new int[] { 16,10, 0, 8,16,
                                    3,16,16,16, 2,
                                    0, 0, 0, 0, 0,
                                   16,16, 1,16,16,
                                   16,16, 1,16,16,
                                   16,13,12,16,16};
            Graphics g = ImagePnl.CreateGraphics();
            DrawImagePanel(g);
        }


        private void Design_BigFaceButton_Click(object sender, EventArgs e)
        {
            this._imagerow = 5;
            this._imagecol = 6;
            ImagePnl.Size = new System.Drawing.Size(52 * this._imagecol + 2, 52 * this._imagerow + 2);
            _imageList = new int[] { 15, 0, 0, 0, 0,14,
                                    1,15,14,15,14, 1,
                                    1,16,16,16,16, 1,
                                    1,16,13,12,16, 1,
                                   13, 0, 0, 0, 0,12};
            Graphics g = ImagePnl.CreateGraphics();
            DrawImagePanel(g);
        }


        private void Design_CustomButton_Click(object sender, EventArgs e)
        {
            this._imagerow = 5;
            this._imagecol = 6;
            ImagePnl.Size = new System.Drawing.Size(52 * this._imagecol + 2, 52 * this._imagerow + 2);
            _imageList = new int[this._imagerow * this._imagecol];
            for (int i = 0; i < this._imagerow * this._imagecol; i++)
                _imageList[i] = 16;
            Graphics g = ImagePnl.CreateGraphics();
            DrawImagePanel(g);
        }


//         private void Design_CustomBigButton(object sender, EventArgs e)
//         {
//             
//         }


        private void ClearImageButton_Click(object sender, EventArgs e)
        {
            ImagePnl.Size = new System.Drawing.Size(52 * this._imagecol + 2, 52 * this._imagerow + 2);
            _imageList = new int[this._imagerow * this._imagecol];
            for (int i = 0; i < this._imagerow * this._imagecol; i++)
                _imageList[i] = 16;
            Graphics g = ImagePnl.CreateGraphics();
            DrawImagePanel(g);
        }


        private void DesignCustB_Click(object sender, EventArgs e)
        {
            this._imagerow = 6;
            this._imagecol = 8;
            ImagePnl.Size = new System.Drawing.Size(52 * this._imagecol + 2, 52 * this._imagerow + 2);
            _imageList = new int[this._imagerow * this._imagecol];
            for (int i = 0; i < this._imagerow * this._imagecol; i++)
                _imageList[i] = 16;
            Graphics g = ImagePnl.CreateGraphics();
            DrawImagePanel(g);
        }


        private void BackToStartPnl_MouseEnter(object sender, EventArgs e)
        {
            BackToStartPnl.BackgroundImage = 主界面.Resource1.canvas_b_on;
        }


        private void BackToStartPnl_MouseLeave(object sender, EventArgs e)
        {
            BackToStartPnl.BackgroundImage = 主界面.Resource1.canvas_b;
        }


        private void ContinuePnl_MouseEnter(object sender, EventArgs e)
        {
            ContinuePnl.BackgroundImage = 主界面.Resource1.canvas_f_on;
        }


        private void ContinuePnl_MouseLeave(object sender, EventArgs e)
        {
            ContinuePnl.BackgroundImage = 主界面.Resource1.canvas_f;
        }


        private void BackToStartPnl_MouseClick(object sender, MouseEventArgs e)
        {
            if (_startFrm == null)
            {
                _startFrm = new StartFrom(this);
                _startFrm.Location = this.Location;
                this.Opacity = 0;
                _startFrm.Show();
//                this.ShowInTaskbar = false;
            }
            else
            {
                _startFrm.Location = this.Location;
                this.Opacity = 0;
                _startFrm.Opacity = 100;
//                _startFrm.ShowInTaskbar = true;
//                this.ShowInTaskbar = false;
            }


        }


        private void ContinuePnl_MouseClick(object sender, MouseEventArgs e)
        {
            if (_imageList != null)
            {
//                 if (_prepareFrm == null)
//                 {
                    _prepareFrm = new PrepareForm(this,_imagerow,_imagecol);
                    _prepareFrm.Location = this.Location;
                    this.Opacity=0;
                    _prepareFrm.Show();
//                 }
//                 else
//                 {
//                     _prepareFrm.Location = this.Location;
//                     this.Opacity = 0;
//                     _prepareFrm.Opacity = 100;
//                 }
            }
            else
            {
                MessageBox.Show("亲,你好像还没有设计图像哦", "啊哦,发生了一个小错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            
        }


        private void DesignForm_Shown(object sender, EventArgs e)
        {
            Design_HeartButton_Click(Design_HeartButton, null);
        }






//         private void DesignForm_Activated(object sender, EventArgs e)
//         {
//             Design_HeartButton_Click(Design_HeartButton, null);
//         }




先写到这里。。。。稍后更新



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: AlphaPose是一个用于姿势估计和人体关键点检测的深度学习框架。该框架的主要目的是利用卷积神经网络来实现快速和准确的人体姿势和关键点检测,从而为计算机视觉技术的应用提供基础支持。AlphaPose提供了许多开源的框架和代码,以便开发人员能够使用该框架来快速搭建姿势估计和人体关键点检测系统。 该框架的核心代码是基于PyTorch实现的。通过使用PyTorch来训练一个高效的深度学习模型,AlphaPose可以自动识别姿势的关键点,并通过特定的方法来对这些关键点进行建模和分析,从而实现准确的姿势估计和人体关键点检测。 AlphaPose框架包含了几个部分,包括数据预处理、模型训练、模型测试和结果分析等。使用该框架进行姿势估计和人体关键点检测的过程需要经历以下几个步骤:首先是数据预处理,AlphaPose提供了方便的数据预处理工具,可以使用该工具经过数据集的标注和格式转换之后,将原始数据集转换成一个可以用于训练和测试的标准数据集;其次是模型训练,AlphaPose提供了一系列训练工具和算法,可以帮助开发人员快速训练高效的深度学习模型;最后是模型测试和结果分析,AlphaPose提供了一系列测试工具和结果分析工具,可以对训练后的模型进行测试和评估,以提高模型的准确性和性能。 总之,AlphaPose是一个功能齐全、易于使用、性能卓越的深度学习框架,它已经被广泛应用于姿势估计和人体关键点检测等计算机视觉领域,成为该领域的一个重要组成部分。 ### 回答2: AlphaPose是深度学习的姿态估计工具,可以通过它快速准确地检测影像的人体姿态。下面是对AlphaPose代码解析的简要介绍。 首先,AlphaPose使用的是卷积神经网络(CNN)技术,它可以对输入的图片进行特征抽取和处理。关键在于如何找到一个好的训练数据集,这个数据集需要包含足够的姿态信息,以便训练模型。AlphaPose采用的是COCO数据集,该数据集包含超过20万个关键点的数据,这些关键点已经过标注,并且分布在超过1000张图片。 其次,AlphaPose使用人体关键点检测(keypoint detection)技术。该技术的目标是检测和识别影像的人体关键点。这些关键点可以提供人体姿态的信息,包括有哪些身体部位,以及它们的位置、角度和方向等等。AlphaPose使用的是Mask R-CNN模型,可以同时进行人体检测和人体关键点检测。 最后,AlphaPose使用的是OpenPose算法,可以将人体检测和人体关键点检测结果进行融合,并得出最终的姿态估计结果。OpenPose算法的优点是不受姿态变化、旋转和光照等影响,具有良好的鲁棒性。这也是为什么AlphaPose能够在检测不同姿态的人体时表现出色的原因。 总体来说,AlphaPose代码的实现离不开深度学习技术的支持。它可以通过训练数据集来不断优化自身模型,以提高姿态检测的准确性和效率。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值