我需要解释OpenCV的boundingRect.我已经实现了它,效果很好.请问有哪些参考资料完整解释?
我已经在我的项目中使用 NuGet 管理器安装了最新的 OpenCVSharp 2 (2.4.10.201...)。有关 OpenCVSharp.CvMat 的所有内容都工作正常(加载、操作等),因此我确信安装是正确的。
但是我根本无法使用 OpenCVSharp.CPlusPlus!问题是它不加载 OpenCvSharpExtern.dll。
try-catch 块显示错误:
try
{
Mat mat = new Mat();
} catch (Exception err)
{
Console.WriteLine( err );
}
System.TypeInitializationException: The type initializer for 'OpenCvSharp.CPlusPlus.Mat' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'OpenCvSharpExtern': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at OpenCvSharp.CPlusPlus.NativeMethods.core_Mat_sizeof()
at OpenCvSharp.CPlusPlus.Mat..cctor()
--- End of inner exception stack trace ---
at OpenCvSharp.CPlusPlus.Mat..ctor()
at MainClass.Main() in C:\Users\kotsias\Documents\Visual Studio 2015\Projects\MyCVSharp\ConsoleApplication1\Test.cs:line 14
Run Code Online (Sandbox Code Playgroud)
OpenCvSharpExtern.dll与我的 …
环境:
这个简单的代码运行良好,没有错误;但是,没有生成图像,也没有显示任何内容,我被迫手动停止代码并中断它退出,否则它似乎会永远运行?这段完全相同的代码在我的 Windows 笔记本电脑上运行良好。有什么线索吗?代码:
import cv2
CV_cat = cv2.imread('Cat.jpg')
cv2.imshow('displaymywindows', CV_cat)
cv2.waitKey(1500)
Run Code Online (Sandbox Code Playgroud) 在python/numpy中是否有任何bulid-in函数可以转换为array = [1, 3, 1, 2]这样的东西:
array = [[0, 1, 0, 0],
[0, 0, 0, 1],
[0, 1, 0, 0],
[0, 0, 1, 0]]
Run Code Online (Sandbox Code Playgroud) 收到 IndexError 错误:yolo_layers 行上标量变量的索引无效。
network = cv2.dnn.readNetFromDarknet('yolov3.cfg', 'yolov3.weights')
layers = network.getLayerNames()
yolo_layers = [layers[i[0] - 1] for i in network.getUnconnectedOutLayers()]
Run Code Online (Sandbox Code Playgroud)
该代码无法在我的 Jupyter 笔记本上运行,但可以在 google collab 上正常运行。不知道为什么。可能是我的python版本?
在OpenCV中,有两种检测线的方法,它们以端点矢量的形式给出类似的结果 - 线段检测器(LSD)和概率霍夫变换.(折扣标准霍夫变换作为给定的输出是根据方程而不是线端点.)
我无法找到这两种线检测方法及其优缺点的比较和对比.因此 - 这两个功能有什么区别?使用一种方法而不是另一种方法有什么特别的好处吗?
另外,还有其他鲜为人知的线路检测方法(如LSD)在某些用例中可能有用吗?
VI 在图像上绘制了一组轮廓点,并将其存储为 2D numpy 数组。轮廓由 2 个 numpy 数组表示,每个数组的 x 和 y 坐标为浮点值。这些坐标不是整数,并且不能与像素完美对齐,但它们确实可以告诉您轮廓点相对于像素的位置。
我希望能够选择轮廓内的像素。我编写了一些与此处给出的答案几乎相同的代码:使用 Python 中的 OpenCV 在轮廓边界内访问像素值
temp_list = []
for a, b in zip(x_pixel_nos, y_pixel_nos):
temp_list.append([[a, b]]) # 2D array of shape 1x2
temp_array = np.array(temp_list)
contour_array_list = []
contour_array_list.append(temp_array)
lst_intensities = []
# For each list of contour points...
for i in range(len(contour_array_list)):
# Create a mask image that contains the contour filled in
cimg = np.zeros_like(pixel_array)
cv2.drawContours(cimg, contour_array_list, i, color=255, thickness=-1)
# Access …Run Code Online (Sandbox Code Playgroud) 正如您所看到的,图像中有一些嘈杂的绿色轮廓。这是迄今为止我使用 OpenCV 和 Python 的最新输出。我还是个初学者,所以我需要你的帮助。
假设我要创建一个全新的脚本并提供该图像并“清理”图像,我将如何做?
我想从名为的视频创建帧project.avi并将它们保存到frameIn文件夹中。但某些类型的错误不让我完成。我怎么解决这个问题。这是代码:
cap = cv2.VideoCapture('project.avi')
currentFrame = 0
while(True):
ret, frame = cap.read()
name = 'frameIn/frame' + str(currentFrame) + '.jpg'
print ("Creating file... " + name)
cv2.imwrite(name, frame)
frames.append(name)
currentFrame += 1
cap.release()
cv2.destroyAllWindows()
Run Code Online (Sandbox Code Playgroud)
错误是:
Traceback (most recent call last):
File "videoreader.py", line 28, in <module>
cv2.imwrite(name, frame)
cv2.error: OpenCV(4.4.0) /private/var/folders/nz/vv4_9tw56nv9k3tkvyszvwg80000gn/T/pip-req-build-2rx9f0ng/opencv/modules/imgcodecs/src/loadsave.cpp:738: error: (-215:Assertion failed) !_img.empty() in function 'imwrite'
Run Code Online (Sandbox Code Playgroud) 简而言之,我试图使用 OpenCVSharp 作为 C# 函数的一部分来计算图像的清晰度。
作为第一次尝试,我使用了拉普拉斯滤波器,如下所示:
int kernel_size = 3;
int scale = 1;
int delta = 0;
int ddepth = image.Type().Depth;
Mat sharpenedImage = image.Laplacian(ddepth, kernel_size, scale, delta);
\* calculate the variance of the laplacian*\
Run Code Online (Sandbox Code Playgroud)
最后,我想要 this 的方差sharpenedImage。
我已经在 Python 中轻松尝试过:
def variance_of_laplacian(image):
lap_val = cv2.Laplacian(image, cv2.CV_8UC1)
return lap_val.var()
Run Code Online (Sandbox Code Playgroud)
lap_val.var()那么C# 中有类似的东西吗?
我找不到任何与此相关的匹配文章。谢谢你!
opencv ×9
python ×6
c# ×2
numpy ×2
python-3.x ×2
.net ×1
c++ ×1
contour ×1
opencv3.0 ×1
python-2.7 ×1
tensorflow ×1
variance ×1
yolo ×1