百度AI开放平台-人像分割: http://ai.baidu.com/tech/body/seg
注意本文后面的话,百度这个技术效果太差劲了,国外这 https://www.remove.bg/ 个比百度强大很多。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;
using Newtonsoft.Json;
using System.Web;
using Newtonsoft.Json.Linq;
using System.ComponentModel;
namespace IDPhoto
{
///
/// Interaction logic for MainWindow.xaml
///
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
Loaded += new RoutedEventHandler(MainWindow_Loaded);
worker = new BackgroundWorker();
worker.DoWork += new DoWorkEventHandler(worker_DoWork);
worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
}
string strImageBase64 = "";
BackgroundWorker worker;
object lockObj = new object();
void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
btnDoWork.IsEnabled = true;
btnDoWork.Visibility = System.Windows.Visibility.Collapsed;
loading.Visibility = Visibility.Collapsed;
}
void worker_DoWork(object sender, DoWorkEventArgs e)
{
if (Common.token == "")
{
Common.token = getAccessToken();
Config.SaveConfig();
}
string sPost = "image=" + HttpUtility.UrlEncode(strImageBase64, Encoding.UTF8) + "&type=foreground";
string sResult = HttpHelper.httpPost("https://aip.baidubce.com/rest/2.0/image-classify/v1/body_seg?access_token=" + Common.token, sPost);
/*