无误的Mat2QImage代码

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/u014682691/article/details/53958092
QImage MainWindow::Mat2QImage(const cv::Mat& InputMat)
{

    cv::Mat TmpMat;


    // convert the color space to RGB

    if (InputMat.channels() == 1)

    {

        cv::cvtColor(InputMat, TmpMat, CV_GRAY2RGB);

        Result=QImage((const uchar*)(TmpMat.data), TmpMat.cols, TmpMat.rows,TmpMat.cols*TmpMat.channels(),
                      QImage::Format_Indexed8);

    }

    else

    {

        cv::cvtColor(InputMat, TmpMat, CV_BGR2RGB);
        // construct the QImage using the data of the mat, while do not copy the data

        Result = QImage((const uchar*)(TmpMat.data), TmpMat.cols, TmpMat.rows,TmpMat.cols*TmpMat.channels(),

                               QImage::Format_RGB888);


    }





    // deep copy the data from mat to QImage

    Result.bits();


    return Result;


}

展开阅读全文

代码无误,却插不进数据库

11-09

用.net和access作的,编译通过可是,当输入用户名,密码等等时,却总是出现“添加失败”,rn困扰我好几天了,并且我的access数据库也已经加入了everyone 的“写的权限”了,哪位高手能rn帮帮忙,真是要抓狂了。。。。rn代码如下:using System;rnusing System.Data;rnusing System.Configuration;rnusing System.Collections;rnusing System.Web;rnusing System.Web.Security;rnusing System.Web.UI;rnusing System.Web.UI.WebControls;rnusing System.Web.UI.WebControls.WebParts;rnusing System.Web.UI.HtmlControls;rnusing System.Data.OleDb;rnrnpublic partial class Region : System.Web.UI.Pagernrn protected void Page_Load(object sender, EventArgs e)rn rnrn rn protected void btnClear_Click(object sender, EventArgs e)rn rn tbxLoginName.Text = " ";rn tbxBlogName.Text = " ";rn tbxPassword.Text = " ";rn tbxEmail.Text = " ";rn rn protected void btnRegion_Click(object sender, EventArgs e)rn rnrnrn rn rn //string strConnection = "Provider=Microsoft.Jet.OleDb.4.0; ";rn //strConnection += @ "Data Source=E:\BLOGDB.mdb ";rn OleDbConnection objConnection = new OleDbConnection( "provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + Server.MapPath( "BLOG.mdb ")); rn // OleDbConnection objConnection = new OleDbConnection(strConnection);rn rn tryrn if(objConnection .State ==ConnectionState.Closed )rn objConnection .Open();rn string inn = "insert into USER_INFO (LoginName,Password,BlogName,Email) values( ' "+this.tbxLoginName.Text.Trim()+ " ', ' "+this.tbxPassword.Text.Trim()+ " ', ' "+this.tbxBlogName.Text.Trim()+ " ', ' "+this.tbxEmail.Text.Trim()+ " ') ";rn rn OleDbCommand cmd = new OleDbCommand(inn, objConnection);rn rn // objConnection.Open();rn cmd.ExecuteNonQuery(); rn objConnection.Close(); rn Response.Write( " ");rn objConnection.Close();rn rn rn catch rn rn Response.Write( " "); rn rn rnrn rn rn 论坛

没有更多推荐了,返回首页