У меня есть следующий код:
using System;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using DlibDotNet;
using DlibDotNet.Extensions;
using OpenCvSharp;
using OpenCvSharp.Extensions;
namespace MyNamespace.CompVis.FaceSwap
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
public MainForm(string title, Bitmap bitmap)
{
this.Text = title;
pictureBox = new PictureBox();
this.Controls.Add(pictureBox);
pictureBox.Dock = DockStyle.Fill;
pictureBox.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox.Image = bitmap;
}
private void MainForm_Load(object sender, EventArgs e)
{
// load the input image
string sPathTemplate = "d:\\facewarp2\\heads\\template.jpg";
System.Drawing.Bitmap nBmpTemplate = Bitmap.FromFile(sPathTemplate) as Bitmap;
string sPathIntruder = "d:\\facewarp2\\heads\\swap.jpg";
System.Drawing.Bitmap nBmpIntruder = Bitmap.FromFile(sPathIntruder) as Bitmap;
// process image
System.Drawing.Bitmap newBitmap = ProcessImage(nBmpTemplate, nBmpIntruder);
}
private System.Drawing.Bitmap ProcessImage(System.Drawing.Bitmap uTemplateImage, System.Drawing.Bitmap uIntruderImage)
{
System.Drawing.Bitmap nClone = uTemplateImage.Clone();
Последняя строка не выполнена.Компилятор говорит мне
The type "object" can't be implicitely cast to "System.Drawing.Bitmap". An explicit conversion exists (possible a conversion is missing).
Что не так с моим кодом?