我将两个PDF文件与PDFBOX版本2合并为一个。第一个得到字体:
name type encoding emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
XXMGEM+Arial-BoldMT TrueType WinAnsi yes yes yes 15 0
XXMGEM+ArialMT TrueType WinAnsi yes yes yes 19 0
XXMGEM+ArialMT CID TrueType Identity-H yes yes yes 27 0
XXMGEM+ArialNarrow-Bold TrueType WinAnsi yes yes yes 40 0
XXMGEM+ArialNarrow TrueType WinAnsi yes yes yes 44 0
Run Code Online (Sandbox Code Playgroud)
第二个:
name type encoding emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
UNTWVR+HelveticaLTCom-Roman CID TrueType Identity-H yes yes yes …Run Code Online (Sandbox Code Playgroud) 我有一个奇怪的问题:
我已经在我的 Pi 上安装了 OpenCV 库。我有一个连接到 Pi 的 Pi Cam(我能够列出所有视频设备,并且能够使用 raspistill 拍照)
但是当我尝试使用 python 从 opencv 获取视频源时
from flask import Flask, render_template, Response
import cv2
app = Flask(__name__)
cap = cv2.VideoCapture(1)
Run Code Online (Sandbox Code Playgroud)
我收到错误:
[ WARN:0] global /tmp/pip-wheel-qd18ncao/opencv-python/opencv/modules/videoio/src/cap_v4l.cpp (893) open VIDEOIO(V4L2:/dev/video0): can't open camera by index
Run Code Online (Sandbox Code Playgroud)
我尝试使用不同的索引(从-1到13)但没有任何效果。
有什么提示吗?
我想读取一个文本文件并将所有行转换为 int 值。我用这个代码。但我真正怀念的是一种“好的”错误处理方式。
use std::{
fs::File,
io::{prelude::*, BufReader},
path::Path
};
fn lines_from_file(filename: impl AsRef<Path>) -> Vec<i32> {
let file = File::open(filename).expect("no such file");
let buf = BufReader::new(file);
buf.lines()
.map(|l| l.expect("Could not parse line"))
.map(|l:String| l.parse::<i32>().expect("could not parse int"))
.collect()
}
Run Code Online (Sandbox Code Playgroud)
问题:如何进行正确的错误处理?上面的例子是“好的 Rust 代码”吗?或者我应该使用这样的东西:
fn lines_from_file(filename: impl AsRef<Path>) -> Vec<i32> {
let file = File::open(filename).expect("no such file");
let buf = BufReader::new(file);
buf.lines()
.map(|l| l.expect("Could not parse line"))
.map(|l:String| match l.parse::<i32>() {
Ok(num) => num,
Err(e) => -1 //Do something here
}).collect() …Run Code Online (Sandbox Code Playgroud)