Посмотрите здесь . Вам нужно захватить координаты мыши и затем использовать cv.line
def click_and_crop(event, x, y, flags, param):
# grab references to the global variables
global refPt, cropping
# if the left mouse button was clicked, record the starting
# (x, y) coordinates and indicate that cropping is being
# performed
if event == cv2.EVENT_LBUTTONDOWN:
refPt = [(x, y)]
cropping = True
# check to see if the left mouse button was released
elif event == cv2.EVENT_LBUTTONUP:
# record the ending (x, y) coordinates and indicate that
# the cropping operation is finished
# y = height x = width
refPt.append((x, y))
cropping = False
# draw a rectangle around the region of interest
#cv.line(input_frame, (0, int(height/2)), (int (width), int(height/2)), (0, 0xFF, 0), 5)
cv2.line(image,(0, int(y)), (int(width), int(y)), (0, 255, 0), 2)
cv2.imshow("image", image)
.
Если Вы находитесь на unix/linux затем, можно провести его через sed.
откройте терминал и тип:
sed 's/ \+/ /g' thefile > thefile.new
это заменяет все последовательности нескольких пробелов с одним пространством.
Можно также использовать ту же команду, отправленную Jauco для изменения разделителя на''; или \n. Это также помогло бы.
Нет ли никакой способ, которым можно сделать это практично? Простой Сценарий PHP смог бы загрузить файл в, разделенный пробелами, и сделать вставку в мгновение ока вообще:
<?php
$db = mysql_connect('host', 'user', 'password')
or die('Failed to connect');
mysql_select_db('database', $db);
$fileHandle= @fopen("import.file", "r");
if ($fileHandle) {
while (!feof($fileHandle)) {
$rawLine = fgets($fileHandle, 4096);
$columns = preg_split("/\s+/", $rawLine);
//Construct and run an INSERT statement here ...
}
fclose($fileHandle);
}
?>
Редактирование Однако предложение Jakal намного более опрятно ;)