用rename()函數實現了多次點擊抓拍,實時顯示用了halcon的多線程。
//抓拍並存儲
int index = 0;
void Cdemo2Dlg::OnBnClickedCancel2()
{
// TODO: 在此添加控件通知處理程序代碼
//要讀取的文件夾路徑
WriteImage(ho_Image, "jpeg", 0, "D:/Desktop/MyPrj/test2/temp/111.jpg");
string newFilePath("D:\\Desktop\\MyPrj\\test2\\image\\"); //重新寫到這個文件夾中
//int index = 0;
char t_str1[100];
_itoa_s(index,t_str1,10); //將i轉換爲圖像命名的一部分
string str(t_str1);
string sNewName1 = newFilePath + str + ".jpg";
rename("D:\\Desktop\\MyPrj\\test2\\temp\\111.jpg",sNewName1.c_str());
index++;
}
拍攝顯示網上太多就不貼了
halcon源代碼及整個程序的代碼如下:
https://download.csdn.net/download/ly117626/10536164