日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

OpenCV曝光参数和快门时间的对应关系

發布時間:2023/12/16 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 OpenCV曝光参数和快门时间的对应关系 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

opencv -Camera曝光設置

1、曝光設置

cv_cap.set(cv::CAP_PROP_AUTO_EXPOSURE, 0.25); // where 0.25 means "manual exposure, manual iris"cv_cap.set(CV_CAP_PROP_EXPOSURE, -13);

2、設置自動曝光為手動曝光

cv_cap.set(cv::CAP_PROP_AUTO_EXPOSURE, 0.25); // where 0.25 means "manual exposure, manual iris"

3、曝光參數具體對應于曝光時間

OpenCV_exposure

快門時間ms

-1

640

-2

320

-3

160

-4

80

-5

40

-6

20

-7

10

-8

5

-9

2.5

-10

1.25

-11

0.625

-12

0.3125

-13

0.15625

-14

0.078125

說明:x為opencv中設置的曝光值OpenCV_exposure

? ? ? ? ? ?y為快門時間

4、代碼實現:

void cameExposureTestAndExposureFusionTest(VideoCapture cap) {int ix = 0;int numImages = 4;Mat frame;vector<Mat> images;//是否圖像映射bool needsAlignment = true;//cap.set()auto i = cap.get(CAP_PROP_EXPOSURE);cout << "設置之前曝光為:" << i << endl;cap.set(CAP_PROP_AUTO_EXPOSURE, 0.25);while (waitKey(30) != 27){ /*int 循環調節 = -13;while (1){if (循環調節 == 0){循環調節 = -13;break;}//cout << "設置之后曝光為:" << cap.get(CAP_PROP_EXPOSURE);cap.set(CAP_PROP_EXPOSURE, 循環調節);//cout << "設置之后曝光為:" << cap.get(CAP_PROP_EXPOSURE)<<endl;cap >> frame;putText(frame, "Exposure:" + to_string(循環調節), Point(20, 30), 3, 1.0, Scalar(255, 0, 0));imshow("調用攝像頭", frame);imwrite("E:\\Project_OpenCV_C++\\openCV_Test1\\openCV_Test3\\cameExposureTest\\" + to_string(循環調節) + ".jpg", frame);waitKey(30);images.push_back(frame);循環調節= 循環調節+1;} */vector<float> times;// 曝光時間列表const float timesArray[] = { 1 / 30.0f,0.25,2.5,15.0 };times.assign(timesArray, timesArray + numImages);// 曝光值列表float OpenCV_exposure[] = {NULL };//這里將快門時間轉換成OpenCV的曝光參數for (ix = 0; ix < 4; ix++){OpenCV_exposure[ix] = -(log(640 / (timesArray[ix]*1000) ) + 1);}for (ix=0; ix<4; ix++){cap.set(CAP_PROP_EXPOSURE, OpenCV_exposure[ix]);cap >> frame;imshow("調用攝像頭", frame);imwrite("E:\\Project_OpenCV_C++\\openCV_Test1\\openCV_Test3\\cameExposureTest\\" + to_string(ix) + ".jpg", frame);waitKey(30);images.push_back(frame);}// Align input imagesif (needsAlignment){cout << "Aligning images ... " << endl;Ptr<AlignMTB> alignMTB = createAlignMTB();alignMTB->process(images, images);}else{cout << "Skipping alignment ... " << endl;}// 獲取圖像響應函數 (CRF)Mat responseDebevec;Ptr<CalibrateDebevec> calibrateDebevec = createCalibrateDebevec();calibrateDebevec->process(images, responseDebevec, times);// Merge using Exposure Fusion 圖像融合cout << "Merging using Exposure Fusion ... " << endl;Mat exposureFusion;Ptr<MergeMertens> mergeMertens = createMergeMertens();mergeMertens->process(images, exposureFusion);imwrite("E:\\Project_OpenCV_C++\\openCV_Test1\\openCV_Test3\\cameExposureTestAndExposureFusionTest\\exposure-fusion.jpg", exposureFusion*255);// 將圖像合并為HDR線性圖像Mat hdrDebevec;Ptr<MergeDebevec> mergeDebevec = createMergeDebevec();mergeDebevec->process(images, hdrDebevec, times, responseDebevec);// 保存圖像imwrite("E:\\Project_OpenCV_C++\\openCV_Test1\\openCV_Test3\\cameExposureTestAndExposureFusionTest\\hdrDebevec.hdr", hdrDebevec);// 使用Drago色調映射算法獲得24位彩色圖像Mat ldrDrago;Ptr<TonemapDrago> tonemapDrago = createTonemapDrago(1.0, 0.7);tonemapDrago->process(hdrDebevec, ldrDrago);ldrDrago = 3 * ldrDrago;imwrite("E:\\Project_OpenCV_C++\\openCV_Test1\\openCV_Test3\\cameExposureTestAndExposureFusionTest\\ldr-Drago.jpg", ldrDrago * 255);// 使用Durand色調映射算法獲得24位彩色圖像 /*Mat ldrDurand;Ptr<TonemapDurand> tonemapDurand = createTonemapDurand(1.5, 4, 1.0, 1, 1);tonemapDurand->process(hdrDebevec, ldrDurand);ldrDurand = 3 * ldrDurand;imwrite("E:\\Project_OpenCV_C++\\openCV_Test1\\openCV_Test3\\cameExposureTestAndExposureFusionTest\\ldr-Durand.jpg", ldrDurand * 255); */// 使用Reinhard色調映射算法獲得24位彩色圖像Mat ldrReinhard;Ptr<TonemapReinhard> tonemapReinhard = createTonemapReinhard(1.5, 0, 0, 0);tonemapReinhard->process(hdrDebevec, ldrReinhard);imwrite("E:\\Project_OpenCV_C++\\openCV_Test1\\openCV_Test3\\cameExposureTestAndExposureFusionTest\\ldr-Reinhard.jpg", ldrReinhard * 255);// 使用Mantiuk色調映射算法獲得24位彩色圖像Mat ldrMantiuk;Ptr<TonemapMantiuk> tonemapMantiuk = createTonemapMantiuk(2.2, 0.85, 1.2);tonemapMantiuk->process(hdrDebevec, ldrMantiuk);ldrMantiuk = 3 * ldrMantiuk;imwrite("ldr-Mantiuk.jpg", ldrMantiuk * 255);imwrite("E:\\Project_OpenCV_C++\\openCV_Test1\\openCV_Test3\\cameExposureTestAndExposureFusionTest\\ldr-Mantiuk.jpg", ldrMantiuk * 255);images.clear();}return; }

總結

以上是生活随笔為你收集整理的OpenCV曝光参数和快门时间的对应关系的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。