过去几天我一直在尝试从图片中获取数独网格,并且一直在努力获取网格的较小方块。我正在处理下面的图片。我认为用精明的过滤器处理图像会正常工作,但它没有,我无法获得每个正方形的每个轮廓。然后我将自适应阈值、otsu 和经典阈值化进行测试,但每次似乎都无法捕捉到每个小方块。
最终目标是获取包含数字的单元格,并使用 pytorch 识别数字,所以我真的很想拥有一些干净的数字图像,这样识别就不会出错:)
有没有人知道如何实现这一目标?非常感谢!:D
我想设置一个 opencv 系统来处理 HLS 流或 RMTP 流,但是,我遇到了一个关于降低的帧速率和累积延迟的奇怪问题。就好像视频离它应该在流中的位置越来越远。
我正在寻找一种方法来与实时源保持同步,即使这意味着丢帧。
import cv2
cap = cv2.VideoCapture()
cap.open('https://videos3.earthcam.com/fecnetwork/9974.flv/chunklist_w1421640637.m3u8')
while (True):
_, frame = cap.read()
cv2.imshow("camCapture", frame)
cv2.waitKey(1)
Run Code Online (Sandbox Code Playgroud)
我已经在 VLC 上验证了流的质量,它似乎在那里工作正常。
.
我正在尝试使用以下代码使用 Kmeans 分割肺部 CT 图像:
def process_mask(mask):
convex_mask = np.copy(mask)
for i_layer in range(convex_mask.shape[0]):
mask1 = np.ascontiguousarray(mask[i_layer])
if np.sum(mask1)>0:
mask2 = convex_hull_image(mask1)
if np.sum(mask2)>2*np.sum(mask1):
mask2 = mask1
else:
mask2 = mask1
convex_mask[i_layer] = mask2
struct = generate_binary_structure(3,1)
dilatedMask = binary_dilation(convex_mask,structure=struct,iterations=10)
return dilatedMask
def lumTrans(img):
lungwin = np.array([-1200.,600.])
newimg = (img-lungwin[0])/(lungwin[1]-lungwin[0])
newimg[newimg<0]=0
newimg[newimg>1]=1
newimg = (newimg*255).astype('uint8')
return newimg
def lungSeg(imgs_to_process,output,name):
if os.path.exists(output+'/'+name+'_clean.npy') : return
imgs_to_process = Image.open(imgs_to_process)
img_to_save = imgs_to_process.copy()
img_to_save = np.asarray(img_to_save).astype('uint8')
imgs_to_process = lumTrans(imgs_to_process)
imgs_to_process = np.expand_dims(imgs_to_process, axis=0)
x,y,z …
Run Code Online (Sandbox Code Playgroud) 我一直在从事涉及徽标检测图像处理的项目。具体来说,目标是为实时FedEx卡车/徽标检测器开发一个自动化系统,该系统可从IP摄像机流中读取帧并发送检测通知。这是运行中的系统的示例,其中已识别的徽标被绿色矩形包围。
对项目的一些限制:
当前实施/算法
我有两个线程:
cv2.VideoCapture()
并调整帧大小以进行进一步处理。决定在单独的线程中处理抓取帧,以通过减少I / O延迟(由于cv2.VideoCapture()
阻塞)来提高FPS 。通过专门用于捕获帧的独立线程,这将允许主处理线程始终具有可用于执行检测的帧。整体伪算法
For each frame:
Find bounding box for purple color of logo
Find bounding box for red/orange color of logo
If both bounding boxes are valid/adjacent and contours pass checks:
Combine bounding boxes
Draw combined bounding boxes on original frame
Play sound notification for detected logo
Run Code Online (Sandbox Code Playgroud)
颜色阈值用于徽标检测
对于颜色阈值,我为紫色和红色定义了HSV(低,高)阈值以检测徽标。
colors = {
'purple': …
Run Code Online (Sandbox Code Playgroud) 我的任务是检测土壤表面的裂缝并计算裂缝的总面积。为此,我使用了Canny边缘检测。
输入图像
结果
下一步是将Canny边缘转换为轮廓,因为我想cv2.mean
使用cv2.contourArea
功能过滤裂纹并使用函数计算其面积。在这一步上,我遇到了问题。当我使用时:
canny_cracks = cv2.Canny(gray, 100, 200)
contours, _ = cv2.findContours(canny_cracks, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
Run Code Online (Sandbox Code Playgroud)
由于边缘边缘的孔,它无法正确转换。在这里看到问题
我的问题是如何连接边缘的末端以封闭边缘之间的孔?
注意:我使用了轮廓检测而不应用Canny边缘。问题在于轮廓检测会产生很多噪声,并且不能很好地检测所有裂缝。或者,也许我不知道如何像精巧的边缘那样找到轮廓。
我必须拼接从许多 (9) 台相机捕获的图像。最初,我尝试从 2 个相机以 15 FPS 的速率捕获帧。然后,我连接了 4 个摄像头(我还使用了外部供电的 USB 集线器来提供足够的电力)但我只能看到一个流。
为了测试,我使用了以下脚本:
import numpy as np
import cv2
import imutils
index = 0
arr = []
while True:
cap = cv2.VideoCapture(index)
if not cap.read()[0]:
break
else:
arr.append(index)
cap.release()
index += 1
video_captures = [cv2.VideoCapture(idx) for idx in arr]
while True:
# Capture frame-by-frame
frames = []
frames_preview = []
for i in arr:
# skip webcam capture
if i == 1: continue
ret, frame = video_captures[i].read()
if ret:
frames.append(frame) …
Run Code Online (Sandbox Code Playgroud) 我有多个图像图表,所有这些图表都包含作为字母数字字符的标签,而不仅仅是文本标签本身。我希望我的 YOLO 模型能够识别其中存在的所有数字和字母数字字符。
我如何训练我的 YOLO 模型来做同样的事情。数据集可以在这里找到。https://drive.google.com/open?id=1iEkGcreFaBIJqUdAADDXJbUrSj99bvoi
例如:查看边界框。我希望 YOLO 检测文本所在的位置。但是目前没有必要识别其中的文本。
图片可以在这里下载
这是我使用 opencv 尝试过的,但它不适用于数据集中的所有图像。
import cv2
import numpy as np
import pytesseract
pytesseract.pytesseract.tesseract_cmd = r"C:\Users\HPO2KOR\AppData\Local\Tesseract-OCR\tesseract.exe"
image = cv2.imread(r'C:\Users\HPO2KOR\Desktop\Work\venv\Patent\PARTICULATE DETECTOR\PD4.png')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)[1]
clean = thresh.copy()
horizontal_kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (15,1))
detect_horizontal = cv2.morphologyEx(thresh, cv2.MORPH_OPEN, horizontal_kernel, iterations=2)
cnts = cv2.findContours(detect_horizontal, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
cnts = cnts[0] if len(cnts) == 2 else cnts[1]
for c in cnts:
cv2.drawContours(clean, [c], -1, 0, 3) …
Run Code Online (Sandbox Code Playgroud) 我正在尝试为我在 google play 商店上的最后一个应用程序的测试版上传一个新的更新。
我试过几个版本代码,1,2,3,29 !! 但是无论设置什么版本代码,都显示这个错误
上传失败您需要为您的 APK 或 Android App Bundle 使用不同的版本代码,因为您已经有一个版本代码为 29 的
请注意,该应用程序的最后一个版本实际上是 1。
这是我的 gradle 应用程序的一部分
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.company.myapp"
minSdkVersion 18
targetSdkVersion 28
versionCode 29
versionName "29.2.5"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
Run Code Online (Sandbox Code Playgroud) 我在 python 中编写了一个小脚本,我试图提取或裁剪扑克牌中仅代表艺术品的部分,删除所有其余部分。我一直在尝试各种阈值方法,但无法到达那里。另请注意,我不能简单地手动记录艺术品的位置,因为它并不总是处于相同的位置或大小,而是始终处于矩形形状,而其他一切都只是文本和边框。
from matplotlib import pyplot as plt
import cv2
img = cv2.imread(filename)
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
ret,binary = cv2.threshold(gray, 0, 255, cv2.THRESH_OTSU | cv2.THRESH_BINARY)
binary = cv2.bitwise_not(binary)
kernel = np.ones((15, 15), np.uint8)
closing = cv2.morphologyEx(binary, cv2.MORPH_OPEN, kernel)
plt.imshow(closing),plt.show()
Run Code Online (Sandbox Code Playgroud)
当前的输出是我能得到的最接近的东西。我可以在正确的方式上尝试进一步争论以在白色部分周围绘制一个矩形,但我认为这不是一种可持续的方法:
最后一点,请参阅下面的卡片,并非所有框架的大小或位置都完全相同,但总会有一件艺术品,周围只有文字和边框。它不必非常精确地切割,但很明显,艺术是卡片的一个“区域”,被包含一些文本的其他区域包围。我的目标是尽可能地捕捉艺术品的区域。
我有这些图片
我想删除背景中的文本。只有captcha characters
应该保留(即 K6PwKA、YabVzu)。任务是稍后使用 tesseract 识别这些字符。
这是我尝试过的,但它并没有给出很好的准确性。
import cv2
import pytesseract
pytesseract.pytesseract.tesseract_cmd = r"C:\Users\HPO2KOR\AppData\Local\Tesseract-OCR\tesseract.exe"
img = cv2.imread("untitled.png")
gray_image = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
gray_filtered = cv2.inRange(gray_image, 0, 75)
cv2.imwrite("cleaned.png", gray_filtered)
Run Code Online (Sandbox Code Playgroud)
我该如何改进?
注意: 我尝试了针对这个问题提出的所有建议,但没有一个对我有用。
编辑: 根据 Elias 的说法,我尝试使用 photoshop 找到验证码文本的颜色,方法是将其转换为灰度,结果介于 [100, 105] 之间。然后我根据这个范围对图像进行阈值处理。但是我得到的结果并没有从tesseract给出令人满意的结果。
gray_filtered = cv2.inRange(gray_image, 100, 105)
cv2.imwrite("cleaned.png", gray_filtered)
gray_inv = ~gray_filtered
cv2.imwrite("cleaned.png", gray_inv)
data = pytesseract.image_to_string(gray_inv, lang='eng')
Run Code Online (Sandbox Code Playgroud)
输出 :
'KEP wKA'
Run Code Online (Sandbox Code Playgroud)
结果 :
编辑 2:
def get_text(img_name):
lower = (100, 100, 100)
upper = (104, 104, 104)
img = …
Run Code Online (Sandbox Code Playgroud)