我使用OpenCV函数和C++将两个图像拼接在一起.现在我遇到的问题是最终图像包含一个大的黑色部分.
最终图像应该是包含有效部分的矩形.我的图片如下:

如何删除黑色部分?
我用4台固定式摄像机.相机不会相对移动.我想将他们的视频图像实时拼接成一个视频图像.
我用这个OpenCV 2.4.10和cv:stitcher类,像这样:
// use 4 video-cameras
cv::VideoCapture cap0(0), cap1(1), cap2(2), cap3(3);
bool try_use_gpu = true; // use GPU
cv::Stitcher stitcher = cv::Stitcher::createDefault(try_use_gpu);
stitcher.setWarper(new cv::CylindricalWarperGpu());
stitcher.setWaveCorrection(false);
stitcher.setSeamEstimationResol(0.001);
stitcher.setPanoConfidenceThresh(0.1);
//stitcher.setSeamFinder(new cv::detail::GraphCutSeamFinder(cv::detail::GraphCutSeamFinderBase::COST_COLOR_GRAD));
stitcher.setSeamFinder(new cv::detail::NoSeamFinder());
stitcher.setBlender(cv::detail::Blender::createDefault(cv::detail::Blender::NO, true));
//stitcher.setExposureCompensator(cv::detail::ExposureCompensator::createDefault(cv::detail::ExposureCompensator::NO));
stitcher.setExposureCompensator(new cv::detail::NoExposureCompensator());
std::vector<cv::Mat> images(4);
cap0 >> images[0];
cap1 >> images[1];
cap2 >> images[2];
cap3 >> images[3];
// call once!
cv::Stitcher::Status status = stitcher.estimateTransform(images);
while(true) {
// **lack of speed, even if I use old frames**
// std::vector<cv::Mat> images(4);
//cap0 …Run Code Online (Sandbox Code Playgroud) I am quite new to OpenCV and DIP in general so I need bit of help in stitching of two images. The problem background is, there are two pieces which have their adhesives/glue torn apart from two joined pieces of plastic. This is the image of "glue" on the base:
and this is the image of "glue" on the other attached face:

As the background of the the images is not the same, I read that it's not possible to …
所以,我正在尝试缝合由微芯片显微镜拍摄的图像,但很难将所有特征对齐.我已经在两个相邻图像之间有50%的重叠,但即便如此,它并不总是很合适.
我正在使用SURF和OpenCV来提取关键点并找到单应矩阵.但是,它仍然远远不是一个可接受的结果.
我的目标是能够完美地缝合2x2图像,所以这样,我可以递归地重复该过程,直到我有最终图像.
你有什么建议吗?一个很好的算法来解决这个问题.或者也许是一种转换图像的方法,以便能够从中提取更好的关键点.使用阈值(较小的一个获得更多的关键点,或更大的关键点?).
现在,我的方法是首先缝合两个2x1图像,然后将这两个图像拼接在一起.它与我们想要的很接近,但仍然不能接受.此外,问题可能是图像曾经是"源"(而第二个图像是通过矩阵与一个图像重叠而变换)可能不会有点错位,或者该图像上的小角度会影响整个结果.
任何帮助或建议表示赞赏.特别是允许使用OpenCV和SURF的任何解决方案(即使我不完全反对其他库......只是因为大部分项目都是用它开发的).
谢谢!
我有许多校准过的相机拍摄平面场景的照片.为简单起见,我们假设有3个摄像头.那些相机正在进行一般运动,但主要是翻译加上一些温和的旋转.相机的示例位置
任务是完全缝合它们.我不了解3D坐标,只是用校准相机拍摄的一组图像.
我所做的:
我在OpenCV中使用SURF/SIFT实现检测特征,通过在每对图像之间使用findHomography来获得初始单应性(1-> 2,2- > 3,1- > 3).从那些单应性我得到每个相机的姿势的初始esitimation (类似的程序到此)
然后我尝试使用束调整技术来最小化每个匹配对的重投影错误.优化参数是三个平移值和三个旋转值(从Rodrigues的旋转公式获得),尽管我可以稍后添加内部参数(焦点,主要点等).
假设图像#2将是参考帧(通过与其他两个图像具有最大量的匹配),其旋转和平移矩阵分别是同一性和零矩阵.
我计算从图像#2到图像#1的关键点(在图像#2和图像#1中均可见)的重投影为(伪代码)
[x1_; y1_; z1_] = K1*R1*inv(K2)*[x2; y2; 1] + K1*T1/Z2;
x1 = x1_/z1_;
y1 = y1_/z1_;
Run Code Online (Sandbox Code Playgroud)
要么
x1 = ((f1/f2)*r11*x2 + (f1/f2)*r12*y2 + f1*r13 + f1*tx/Z2) / ((1/f2)*r31*x2 + (1/f2)*r32*y2 + r33 + tx/Z2)
y1 = ((f1/f2)*r21*x2 + (f1/f2)*r22*y2 + f1*r23 + f1*ty/Z2) / ((1/f2)*r31*x2 + (1/f2)*r32*y2 + r33 + ty/Z2)
Run Code Online (Sandbox Code Playgroud)
其中r__是R1矩阵的元素,两个内在矩阵都是
[f 0 0]
[0 f 0]
[0 0 1]
Run Code Online (Sandbox Code Playgroud)
我假设参考帧的Z2坐标为1.
下一阶段是使用所获得的相机矩阵(K1,R1,T1,K3,R3,T3)将图像#1和#3变形为图像#2的公共坐标系.
问题是我不知道正确重投影到图像#2的参考帧所需的Z1和Z3,因为来自图像#1 - …
opencv computer-vision photogrammetry perspectivecamera image-stitching
我有一个固定相机,可以快速拍摄连续移动的产品的照片,但处于相同角度(平移视角)的固定位置。我需要将所有图像拼接成全景图。我尝试过使用 Stitcher 类。它有效,但计算时间很长。我还尝试使用另一种方法,即使用 SIFT 检测器 FNNbasedMatcher,查找单应性,然后扭曲图像。如果我只使用两个图像,此方法效果很好。对于多个图像,它仍然无法正确缝合它们。有谁知道这种情况下最好、最快的图像拼接算法?
这是我使用 Stitcher 类的代码。
import time
import cv2
import os
import numpy as np
import sys
def main():
# read input images
imgs = []
path = 'pics_rotated/'
i = 0
for (root, dirs, files) in os.walk(path):
images = [f for f in files]
print(images)
for i in range(0,len(images)):
curImg = cv2.imread(path + images[i])
imgs.append(curImg)
stitcher = cv2.Stitcher.create(mode= 0)
status ,result = stitcher.stitch(imgs)
if status != cv2.Stitcher_OK:
print("Can't stitch images, error code = %d" % …Run Code Online (Sandbox Code Playgroud) python opencv image-processing computer-vision image-stitching
我正在使用以下代码来拼接输入图像.由于未知原因输出结果是垃圾!似乎单应矩阵是错误的(或者被错误地影响),因为变换的图像就像一个"被利用的星"!我已经评论了我认为是问题根源但我无法实现的部分.任何帮助或观点都是适当的!
祝你有美好的一天,阿里
void Stitch2Image(IplImage *mImage1, IplImage *mImage2)
{
// Convert input images to gray
IplImage* gray1 = cvCreateImage(cvSize(mImage1->width, mImage1->height), 8, 1);
cvCvtColor(mImage1, gray1, CV_BGR2GRAY);
IplImage* gray2 = cvCreateImage(cvSize(mImage2->width, mImage2->height), 8, 1);
cvCvtColor(mImage2, gray2, CV_BGR2GRAY);
// Convert gray images to Mat
Mat img1(gray1);
Mat img2(gray2);
// Detect FAST keypoints and BRIEF features in the first image
FastFeatureDetector detector(50);
BriefDescriptorExtractor descriptorExtractor;
BruteForceMatcher<L1<uchar> > descriptorMatcher;
vector<KeyPoint> keypoints1;
detector.detect( img1, keypoints1 );
Mat descriptors1;
descriptorExtractor.compute( img1, keypoints1, descriptors1 );
/* Detect FAST keypoints and …Run Code Online (Sandbox Code Playgroud) 我在matlab中尝试缝合图像,但得到难看的重叠线条.如何正确混合图像?目前我正在使用下面的代码,但它混合得太多(特别是建筑物窗户与幽灵文物混合,黑色建筑物也是如此).

%Tx - how much to move picture by x, Ty - by y (homography)
cropX = size(imcyl2, 2); %second image x size
xdimfirst = size(imcyl1, 2); %first image x size
ydimfirst = size(imcyl1, 1); %first image y size
xoverlap = xdimfirst - Tx;
newImg = imcyl1;
for y = 1:size(imcyl2, 1)
for x = 1:cropX
if ((Tx+x) > 0 && (Ty+y) >0)
% if we are in the overlap region, then we need to blend.
scale1 = (xoverlap - …Run Code Online (Sandbox Code Playgroud) 我使用opencv的全景拼接算法,以便将2或3个图像拼接成一个新的结果图像.
我有每个源图像中的点坐标.我需要计算结果图像中这些点的新坐标.
我在下面描述算法.我的代码类似于opencv(分支3.4)中的"stitching_detailed"示例.产生了一种result_mask类型Mat,也许是解决方案?但我不知道如何使用它.我在这里找到了一个相关的问题,但没有找到缝合.
任何的想法?
找到features每个图像:
Ptr<FeaturesFinder> finder = makePtr<SurfFeaturesFinder>()
vector<ImageFeatures> features(num_images);
for (int i = 0; i < num_images; ++i)
{
(*finder)(images[i], features[i]);
}
Run Code Online (Sandbox Code Playgroud)
制作pairwise_matches:
vector<MatchesInfo> pairwise_matches;
Ptr<FeaturesMatcher> matcher = makePtr<BestOf2NearestMatcher>(false, match_conf);
(*matcher)(features, pairwise_matches);
Run Code Online (Sandbox Code Playgroud)
重新排序图像:
vector<int> indices = leaveBiggestComponent(features, pairwise_matches, conf_thresh);
# here some code to reorder 'images'
Run Code Online (Sandbox Code Playgroud)
估计单应性cameras:
vector<CameraParams> cameras;
Ptr<Estimator> estimator = makePtr<HomographyBasedEstimator>();
(*estimator)(features, pairwise_matches, cameras);
Run Code Online (Sandbox Code Playgroud)
转换为CV_32F: …
我很难理解函数cv::detail::leaveBiggestComponent的工作原理,因为几乎没有可用的文档。
我知道该函数应该做什么,也就是说,给定图像之间的一组关键点匹配,返回具有一致匹配的最大图像子集。此外,根据其实现的规定,它还应该删除图像重复项。
该函数是 opencv Stitching Pipeline的一部分,如果引用 Brown 和 Lowe 论文,则应作为全景识别模块执行。
但是,当涉及到分解代码时,我无法真正理解这是如何完成的。
TL;DR我正在寻找 cv::detail::leaveBiggestComponent() 流程图的伪代码解释,请帮助。
代码实现在这里。它从此处(实现)和此处(标头)调用相关代码(也没有文档)。
特别令人感兴趣的是 cv::detail::DisjointSets() 的工作原理。