一个简单的问题,但我无法在那里找到一些东西......
是否有一个简单且用户友好的工具可以在 a 中使用jupyter-notebook,让用户在运行单元格后在空白区域(比如大小(x,y)像素)上绘制黑色内容?
绘图必须作为数组/图像返回(或什至暂时保存),然后可以由numpy例如使用。
import numpy as np
import seaborn as sns; sns.set()
import matplotlib.pyplot as plt
fmri = sns.load_dataset("fmri")
fmri.sort_values('timepoint',inplace=True)
ax = sns.lineplot(x="timepoint", y="signal", data=fmri)
arr = np.ones(len(fmri))
arr[:300] = 0
arr[600:] = 2
fmri['background'] = arr
ax = sns.lineplot(x="timepoint", y="signal", hue="event", data=fmri)
Run Code Online (Sandbox Code Playgroud)
我需要检索相机的位置和姿态角度(使用OpenCV/Python).
偏航是水平面上相机的大致方向:朝北= 0,朝东= 90°,南= 180°,西= 270°等.
俯仰是摄像机的"鼻子"方向:0°=水平地看地平线上的点,-90°=垂直向下看,+ 90°=垂直向上看,45°=向上看45°角从地平线等
如果相机在您手中向左或向右倾斜时会滚动(因此,当此角度变化时,它总是在地平线上观察点):+ 45°=当您抓住相机时,顺时针旋转倾斜45°,因此+ 90°(和-90°)将是肖像图片所需的角度,例如等.
我的世界参考框架是这样的:
向东= + X
向北= + Y
向天空= + Z.
我的世界对象点在该参考系中给出.
现在,从cv2.solvepnp()一堆图像点和它们相应的世界坐标,我已经计算了两个rvec和tvec.但是,根据以下文档:http://docs.opencv.org/trunk/d9/d0c/group__calib3d.html#ga549c2075fac14829ff4a58bc931c033d,它们是:
rvec ; 输出旋转矢量(请参阅
Rodrigues())tvec,它将点从模型坐标系带到摄像机坐标系.
tvec ; 输出翻译矢量.
这些载体被给予去到相机参考帧.
我需要进行精确的逆操作,从而检索相对于世界坐标的摄像机位置和姿态.
所以,我已经计算从旋转矩阵rvec有Rodrigues():
rmat = cv2.Rodrigues(rvec)[0]
Run Code Online (Sandbox Code Playgroud)
如果我就在这里,在世界坐标系中表示的摄像机位置由下式给出:
camera_position = -np.matrix(rmat).T * np.matrix(tvec)
Run Code Online (Sandbox Code Playgroud)
(src:来自cv :: solvePnP的世界坐标中的相机位置)
这看起来相当不错.
我在尝试从脚本对某些数据库执行一些 I/O 操作时遇到了麻烦Python3。
当我想要连接到数据库时,我习惯性地使用psycopg2to 来处理连接和游标。
我的数据通常存储为and/or的等效项。 Pandas DataFramesGeoPandasGeoDataFrames
Pandas:我可以依赖它.read_sql()作为参数的方法con,如文档中所述:
con : SQLAlchemy connectable (engine/connection) or database str URI
or DBAPI2 connection (fallback mode)'
Using SQLAlchemy makes it possible to use any DB supported by that
library. If a DBAPI2 object, only sqlite3 is supported. The user is responsible
for engine disposal and connection closure …Run Code Online (Sandbox Code Playgroud) 在 Ubuntu 21.10 上,实际上没有安装 Python2.x,在大型项目上执行“npm install”时,我遇到以下错误(很大,package.json但这两行可能相关:
...
"devDependencies": {
...
"sass": "^1.46.0",
"sass-loader": "10.1.1",
...
Run Code Online (Sandbox Code Playgroud)
)
$ npm install
npm ERR! code 1
npm ERR! git dep preparation failed
npm ERR! command /usr/bin/node /usr/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/home/username/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit --include=dev --include=peer --include=optional --no-package-lock-only --no-dry-run
npm ERR! npm WARN using --force Recommended protections disabled.
npm ERR! npm WARN old lockfile
npm ERR! npm WARN old lockfile The package-lock.json file was created with an old version …Run Code Online (Sandbox Code Playgroud) 我正在寻找一个与 Django 一起使用的 CSS 框架,最终找到了 boostrap 5。
但似乎有两个包的名称几乎相同。
那么,哪一个是从 Django 中的 PyPi 加载的正确 bootstrap 5 包(如果有):
?
我在那儿遵循安装指南:http :
//wiki.ros.org/melodic/Installation/Ubuntu
但:
$ sudo apt-get install ros-melodic-desktop-full 不起作用:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
ros-melodic-desktop-full : Depends: …Run Code Online (Sandbox Code Playgroud)在docker-compose.yml 文件中,我真的需要指定volumes两次吗?服务内部和外部?如果是,为什么?(文档的 docker-compose 部分没有太多相关信息)
我的感觉是,在这里显示的情况下,myapp卷不是主机上明确的文件夹,我们必须将其设置两次,但如果它实际上是主机上的文件夹,则仅在frontend服务块内指定它足够。
此外,当在服务块之外指定卷时,它几乎总是写为key:没有任何实际值(或有时写为key: {}),这让我感到困惑。
此外,当我运行时,docker-compose down -v它实际上仅适用于未明确指定为主机上的文件夹的卷,根据文档:
-v, --volumes Remove named volumes declared in the `volumes`
section of the Compose file and anonymous volumes
attached to containers.
Run Code Online (Sandbox Code Playgroud)
因此,在服务之外声明卷可能是为了使该卷可识别,从而“可移动”。另一方面,如果它没有设置在服务之外,它就永远无法删除?
听起来好像在 PostGIS Docker 镜像中找不到 PostGIS 本身。因此,我想我一定是在某个地方错了,但我无法弄清楚。这是我每次基于下面的 Dockerfile 构建和启动容器时遇到的错误:
(...)
app_1 | /usr/local/bin/docker-entrypoint.sh: sourcing /docker-entrypoint-initdb.d/10_postgis.sh
app_1 | CREATE DATABASE
app_1 | Loading PostGIS extensions into template_postgis
app_1 | 2021-02-20 00:09:20.414 CET [91] ERROR: could not access file "$libdir/postgis-3": No such file or directory
app_1 | 2021-02-20 00:09:20.414 CET [91] STATEMENT: CREATE EXTENSION IF NOT EXISTS postgis;
app_1 | ERROR: could not access file "$libdir/postgis-3": No such file or directory
Run Code Online (Sandbox Code Playgroud)
这是生成此错误的 Dockerfile:
FROM postgis/postgis:13-3.1
ENV POSTGRES_DB=somedb
ENV POSTGRES_USER=someuser
ENV POSTGRES_PASSWORD=****
# Dont …Run Code Online (Sandbox Code Playgroud) 我有一个 2D NumPy数组,其中包含二进制值(0 和 1)+1 个附加值(-999),表示“无数据”。
这是一个虚拟示例:
import numpy as np
arr = np.random.randint(2, size=(100,))
# this no-data value has to be large compared to the data range:
arr[np.random.randint(1, 100, 20)] = -999
arr = arr.astype(np.float32)
arr.reshape((10,10))
>> arr
array([[ 1, 1, 0, 1, 0, 0, -999, 1, 0, 0],
[ 0, 1, 0, 0, 1, 0, 1, 1, 1, 1],
[ 1, 1, 1, 1, -999, 0, 1, -999, 1, -999],
[ 0, 1, -999, 1, 0, 1, …Run Code Online (Sandbox Code Playgroud) python ×4
dataframe ×2
docker ×2
pandas ×2
arrays ×1
boost ×1
bootstrap-5 ×1
django ×1
dockerfile ×1
geopandas ×1
graph ×1
imshow ×1
matplotlib ×1
node-gyp ×1
node-sass ×1
node.js ×1
npm ×1
npm-install ×1
numpy ×1
postgis ×1
postgresql ×1
psycopg2 ×1
ros ×1
seaborn ×1
sqlalchemy ×1
ubuntu ×1
user-input ×1