我正在尝试从2d立体图像中理解3d点重建的基础知识.到目前为止我所理解的可归纳如下:
对于3d点(深度图)重建,我们需要来自2个不同视图的同一对象的2个图像,给定这样的图像对我们还需要相机矩阵(比如P1,P2)
我们使用SIFT或SURF等方法在两个图像中找到相应的点.
在得到相应的关键点后,我们发现使用最少8个关键点(用于8点算法)找到基本矩阵(比如K)
鉴于我们在相机1,计算相机2的参数使用基本矩阵返回4个可能的相机参数
最后,我们使用三角测量法使用相应的点和两个相机参数进行三维点估计.
在完成理论部分后,作为我的第一个实验,我尝试运行此处提供的代码,其工作正常.在example.py代码中进行了一些修改后,我尝试在所有连续图像对上运行此示例,并合并三维点云以进行对象(dino)的三维重建,如下所示:
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import cv2
from camera import Camera
import structure
import processor
import features
def dino():
# Dino
img1 = cv2.imread('imgs/dinos/viff.003.ppm')
img2 = cv2.imread('imgs/dinos/viff.001.ppm')
pts1, pts2 = features.find_correspondence_points(img1, img2)
points1 = processor.cart2hom(pts1)
points2 = processor.cart2hom(pts2)
fig, ax = plt.subplots(1, 2)
ax[0].autoscale_view('tight')
ax[0].imshow(cv2.cvtColor(img1, cv2.COLOR_BGR2RGB))
ax[0].plot(points1[0], points1[1], 'r.')
ax[1].autoscale_view('tight')
ax[1].imshow(cv2.cvtColor(img2, cv2.COLOR_BGR2RGB))
ax[1].plot(points2[0], points2[1], 'r.')
fig.show()
height, width, ch = …Run Code Online (Sandbox Code Playgroud) 我有一些用c ++编写的代码,我试图在python中使用而不再重写python中的完整代码,我使用Pybind11为它构建一个python模块.我试图通过以下教程在Microsoft Visual Studio 2015中实现此功能https://pybind11.readthedocs.io/en/stable/basics.html
我在视觉工作室做了一些事情.1)从https://codeload.github.com/pybind/pybind11/zip/master下载了Pybind11
2)解压缩文件
3)在visual studio中,启动了一个新的空C++项目.
4)在VC++目录> include目录中添加了我的python解释器include文件夹(C:/ python27/include)和Pybind11(C:/ Pybind11/include)
5)在链接器>输入>附加依赖项中添加了其他依赖项(C:\ Python27\libs\python27.lib)
6)要在Python中使用输出文件,我需要一个.pyd文件,所以我在这里修改了配置属性>常规>目标扩展:.pyd
7)将项目默认值>配置类型更改为动态库(.dll)
所以我能够构建我的项目并生成.pyd文件但是在导入这个模块时我收到以下错误:ImportError:动态模块没有定义init函数(initProject11)
我搜索了这个错误并得到了这个链接http://pybind11.readthedocs.io/en/stable/faq.html 但我找不到我的解决方案.
所以我正在寻找上述问题的解决方案.非常感谢提前.
这是我的CPP文件代码
#include <pybind11/pybind11.h>
int add(int i, int j) {
return i + j;
}
namespace py = pybind11;
PYBIND11_PLUGIN(example) {
py::module m("example", "pybind11 example plugin");
m.def("add", &add, "A function which adds two numbers");
return m.ptr();
}
Run Code Online (Sandbox Code Playgroud) 我正在开发一个图像搜索项目,我已经使用自己的算法定义/提取了关键点功能.最初我只提取了单个功能并尝试使用cv2.FlannBasedMatcher()进行匹配,并且它工作正常,我已经实现如下:
Here vec is 2-d list of float values of shape (10, )
Ex:
[[0.80000000000000004, 0.69999999999999996, 0.59999999999999998, 0.44444444444444448, 0.25, 0.0, 0.5, 2.0, 0, 2.9999999999999996]
[2.25, 2.666666666666667, 3.4999999999999996, 0, 2.5, 1.0, 0.5, 0.37499999999999994, 0.20000000000000001, 0.10000000000000001]
[2.25, 2.666666666666667, 3.4999999999999996, 0, 2.5, 1.0, 0.5, 0.37499999999999994, 0.20000000000000001, 0.10000000000000001]
[2.25, 2.666666666666667, 3.4999999999999996, 0, 2.5, 1.0, 0.5, 0.37499999999999994, 0.20000000000000001, 0.10000000000000001]]
vec1 = extractFeature(img1)
vec2 = extractFeature(img2)
q1 = np.asarray(vec1, dtype=np.float32)
q2 = np.asarray(vec2, dtype=np.float32)
FLANN_INDEX_KDTREE = 0
index_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5)
search_params …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个 lambda 函数,该函数接受图像作为多部分/表单数据,对图像进行一些处理并将其上传到 s3,并将响应返回给客户端。但我陷入了使用 API 网关将图像上传到 aws lambda 的第一部分。我尝试在 NodeJS 中执行此操作,如下所示:
exports.handler = async (event, context, callback) => {
var buf = Buffer.from(event.body.replace(/^data:image\/\w+;base64,/, ""),"base64");
var data = {
Bucket: "bucket-name",
Key: "abc.jpg",
Body: buf,
ContentType: 'image/jpg',
ACL: 'public-read'
};
data = await s3.upload(data).promise();
return {
statusCode: 200,
body: JSON.stringify(buf),
};
Run Code Online (Sandbox Code Playgroud)
通过向 api 发出 POST 请求,我在 Postman 中收到以下响应:
{
"ETag": "\"b0e5b18d38904f109e0aef0b29e132be\"",
"Location": "https://bucket-name.s3.us-east-2.amazonaws.com/abc.jpg",
"key": "abc.jpg",
"Key": "abc.jpg",
"Bucket": "bucket-name"
}
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试使用上述响应中返回的公共网址在浏览器中查看上传的图像时,我得到的是空图像。
有人可以指出我这里的错误或建议一些更好的方法吗?谢谢。
我正在尝试检测所有方形骰子图像,以便我可以单独裁剪它们并将其用于OCR。以下是原始图片:
这是我得到的代码,但缺少一些正方形。
def find_squares(img):
img = cv2.GaussianBlur(img, (5, 5), 0)
squares = []
for gray in cv2.split(img):
for thrs in range(0, 255, 26):
if thrs == 0:
bin = cv2.Canny(gray, 0, 50, apertureSize=5)
bin = cv2.dilate(bin, None)
else:
_retval, bin = cv2.threshold(gray, thrs, 255, cv2.THRESH_BINARY)
bin, contours, _hierarchy = cv2.findContours(bin, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
for cnt in contours:
cnt_len = cv2.arcLength(cnt, True)
cnt = cv2.approxPolyDP(cnt, 0.02*cnt_len, True)
if len(cnt) == 4 and cv2.contourArea(cnt) > 1000 and cv2.isContourConvex(cnt):
cnt = cnt.reshape(-1, 2)
max_cos …Run Code Online (Sandbox Code Playgroud) 我正在 JavaScript 中执行图像处理操作,该操作按预期工作,但有时它会冻结 UI,这使得我使用 Web Worker 来执行图像处理功能。我有一个场景,我需要处理多个。以下是我用来实现上述壮举的工作流程的摘要。
//closure
var filter = (function(){
function process(args){
var promise = new Promise(function (resolve, reject) {
if (typeof (Worker) !== "undefined") {
if (typeof (imgWorker) == "undefined") {
imgWorker = new Worker("/processWorker.js");
}
imgWorker.postMessage(args);
imgWorker.onmessage = function (event) {
resolve(event.data);
};
} else {
reject("Sorry, your browser does not support Web Workers...");
}
});
return promise;
}
return {
process: function(args){
return process(args);
}
}
})();
function manipulate(args, callback){
filter.process(args).then(function(res){
callback(res);
});
}
Run Code Online (Sandbox Code Playgroud)
在这里,我正在加载多个图像并将它们传递到 …
我需要计算 numpy 矩阵中唯一值的频率,所以首先我使用了我自己的方法,如下所示:
mat = np.matrix([[1, 2], [3, 4],..])
dic = {}
for i in mat:
for j in i:
if j in dic:
dic[j] += 1
else:
dic[j] = 0
Run Code Online (Sandbox Code Playgroud)
但是这种方法对于高阶矩阵来说是昂贵的,例如 1000X1000 在时间方面,所以为了减少我尝试使用numpy.bincount但我得到 ValueError 的时间。有没有更好的方法来获取矩阵中值的频率计数?提前致谢。
python ×5
opencv ×2
amazon-s3 ×1
aws-lambda ×1
aws-sdk ×1
c++ ×1
es6-promise ×1
flann ×1
image ×1
javascript ×1
node.js ×1
numpy ×1
pybind11 ×1
web-worker ×1