小编Fer*_*nce的帖子

AttributeError: 模块 'cv2.cv2' 在 OpenCV 中没有属性 'freetype'

我正在使用安装了最少软件包的 docker 容器。我安装了opencv-contrib-pythonusingpip3 install opencv-contrib-python并安装了最新版本,4.1.025并已验证它正在运行并且我的程序可以正常运行。但是,现在我需要该freetype模块,但是当我尝试时:

import cv2 as cv
ft = cv.freetype.createFreeType2()
Run Code Online (Sandbox Code Playgroud)

它抛出AttributeError标题中的as 。我尝试重新安装不同的版本,即:4.0.0.21, 4.0.1.23, 4.0.1.24, 4.1.0.25无济于事。我主要使用无头版本(因为我使用的是 docker 并且我不需要任何 gui 功能)。我发现的另一件事是,并非我尝试过的所有模块都可以导入(ccalib、tracking、sfm、xobjdetect 等),并且这些模块会引发相同的错误。这是否意味着某些模块无法通过pip3安装获得?谢谢你。

python freetype2 ubuntu-18.04 opencv4

5
推荐指数
1
解决办法
982
查看次数

自定义react-select可创建选择组件和reach-hook-form打字稿错误

我有一个使用反应选择的自定义组件。这使用了Createable Selectand 看起来像:

import CreatableSelect from "react-select/creatable";
import {
  ActionMeta,
  MultiValue,
  MultiValueGenericProps,
  OptionProps,
  StylesConfig,
  components,
} from "react-select";


type UserOption = {
  value: number;
  label: string;
  logo?: string;
};


type CustomUserInputProps = {
  userOptions: UserOption[];
  onChange: (
    newValue: MultiValue<UserOption>,
    actionMeta: ActionMeta<UserOption>
  ) => void;
  onBlur: ChangeEventHandler;
  value: UserOption[];
  name: string;
}


export function CustomUserInput ({
  userOptions,
  onChange,
  onBlur,
  value,
  name,
  disabled,
  isEdited,
}: CustomUserInputProps ) {
   ...
   return (
         <CreatableSelect
          options={userOptions}
          onChange={onChange}
          placeholder={""}
          isMulti={true}
          onBlur={onBlur}
          value={value}
          name={name}
          components={{ …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs react-select react-hook-form

5
推荐指数
1
解决办法
715
查看次数