lens

Correct barrel distortion in OpenCV manually, without chessboard image

跟風遠走 提交于 2019-11-29 10:04:45
问题 I get images from a camera where it is not possible to take a chessboard picture and calculate the correction matrix using OpenCV. Up to now I corrected the images using imagemagick convert with the option '-distort Barrel "0.0 0.0 -0.035 1.1"' where I got the parameters with trial and error. Now I want to do this inside OpenCV but all I find in the web is the automatic correction using the chessboard image. Is there any chance to apply some simple manual trial and error lens distortion

Combining lenses

风格不统一 提交于 2019-11-29 09:17:23
Using a lens library I can apply a modification function to individual targets, like so: Prelude Control.Lens> (1, 'a', 2) & _1 %~ (*3) (3,'a',2) Prelude Control.Lens> (1, 'a', 2) & _3 %~ (*3) (1,'a',6) How can I combine those individual lenses ( _1 and _3 ) to be able to perform this update to both of the targets at once? I expect something in the spirit of the following: Prelude Control.Lens> (1, 'a', 2) & ??? %~ (*3) (3,'a',6) Using untainted from the Settable type class in Control.Lens.Internal.Setter , it is possible to combine two setters, but the result will also only be a setter and

无重复字符的最长子串

☆樱花仙子☆ 提交于 2019-11-29 03:25:24
一、题目 给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。 示例 1: 输入: "abcabcbb" 输出: 3 解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。 示例 2: 输入: "bbbbb" 输出: 1 解释: 因为无重复字符的最长子串是 "b",所以其长度为 1。 示例 3: 输入: "pwwkew" 输出: 3 解释: 因为无重复字符的最长子串是 "wke",所以其长度为 3。 请注意,你的答案必须是 子串 的长度,"pwke" 是一个子序列,不是子串。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/longest-substring-without-repeating-characters 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 二、解答 1.本人是小白一枚,对于这道题,第一个萌生的念头就是暴力解法,穷举嘛,使用for循环,写出了如下猪狗不如的代码: def lengthOfLongestSubstring(s): if len(s) == 0: return 0 all_len: [int] = [] sub_str_index: [int] = [] # 存放子串 sub_str_str: [str] = [] for index, elem

What is the difference between `ix` and `at` in the Lens library of Haskell

风流意气都作罢 提交于 2019-11-29 02:57:30
All I know is that one works and the other doesn't. Context: I have one data structure F which contains a Data.Map.Map k S to another data structure S . My goal was to build a Lens that given an F and k would describe a field in S . The difficulty is that the key k may not be present in the map. That's fine the function can wrap its return in Maybe. However I could not propagate a lens through a Maybe using at . After reading a lot of Stack Overflow answers, I came across this one . It turns out that replacing at with ix solved my type problems if I also replaced (^.) with (^?) . Question: It

【洛谷T96628】统计

若如初见. 提交于 2019-11-29 01:29:06
Description 给定$n$, $m$,求十进制$n$位数每个位数之积等于k的方案数 Solution dp+高精+数学 考虑$k=0$的情况,由于可以有若干个$0$,所以方案数为$\sum\limits_{i=1}^{n}{n\choose m}\times 9^{n-i}$ 考虑另外的情况,我们将$k$分解质因数,如果$k$还有除了$2$,$3$,$5$,$7$之外的质因数那么方案数为$0$ 其余的情况我们考虑一个$dp$,定义$f[i][j][k][l][o]$表示考虑前$i$位,前$i$位之积$=2^j\times 3^k\times 5^l\times7^o$的方案数是多少,显然第一维可以用滚动数组压掉,转移就类似于背包的转移即可。 由于本题十分恶心的没有取模,所以我们需要高精度计算 Code #include <bits/stdc++.h> // check if it is judged online #define LOCAL namespace shl { const int mod = 10; int n, k; typedef unsigned long long ull; ull C[55][55]; ull ans[60]; ull sum[60]; int lens = 1, lena = 1; using std::max; int f[32]

Using a Lens to read multiple fields

試著忘記壹切 提交于 2019-11-29 01:18:10
Given the types data Prisoner = P { _name :: String , _rank :: Int , _cereal :: Cereal } data Cereal = C { _number :: Int , _percentDailyValue :: Map String Float , _mascot :: String } I could extract someone's name, rank, and cereal number via pattern matching: getNameRankAndCerealNumber_0 :: Prisoner -> (String, Int, Int) getNameRankAndCerealNumber_0 (P { _name=name , _rank=rank , _cereal = C { _number=cerealNumber }} ) = (name, rank, cerealNumber) Alternately, I could use lenses to extract each part separately makeLenses ''Cereal makeLenses ''Prisoner getNameRankAndCerealNumber_1 ::

Combining lenses

久未见 提交于 2019-11-28 02:41:58
问题 Using a lens library I can apply a modification function to individual targets, like so: Prelude Control.Lens> (1, 'a', 2) & _1 %~ (*3) (3,'a',2) Prelude Control.Lens> (1, 'a', 2) & _3 %~ (*3) (1,'a',6) How can I combine those individual lenses ( _1 and _3 ) to be able to perform this update to both of the targets at once? I expect something in the spirit of the following: Prelude Control.Lens> (1, 'a', 2) & ??? %~ (*3) (3,'a',6) 回答1: Using untainted from the Settable type class in Control

What is the difference between `ix` and `at` in the Lens library of Haskell

旧城冷巷雨未停 提交于 2019-11-27 17:13:41
问题 All I know is that one works and the other doesn't. Context: I have one data structure F which contains a Data.Map.Map k S to another data structure S . My goal was to build a Lens that given an F and k would describe a field in S . The difficulty is that the key k may not be present in the map. That's fine the function can wrap its return in Maybe. However I could not propagate a lens through a Maybe using at . After reading a lot of Stack Overflow answers, I came across this one. It turns

Python:如何求数组连续最大值

本秂侑毒 提交于 2019-11-27 16:40:53
1.重复利用已经计算的子数组和:O(n 2 ) def maxSubArr(arr): if arr == None: print('数组为空') return maxsum = -2**31 i = 0 lens = len(arr) while i<lens : j = i sums = 0 while j<lens : sums += arr[j] if sums > maxsum : maxsum = sums j += 1 i += 1 return maxsum 2.动态规划法:O(n) def maxSubArr(arr): lens = len(arr) if arr == None or lens<1 : print('参数不合法') return ends = alls = arr[0] i = 1 while i<lens : ends = max(ends+arr[i], arr[i]) #包含最后一个元素的最大子数组和 alls = max(ends, alls) #最大子数组和 i += 1 return alls 来源: https://blog.csdn.net/weixin_42712658/article/details/99698085

@loj - 3049@ 「十二省联考 2019」字符串问题

浪尽此生 提交于 2019-11-27 12:02:15
目录 @description@ @solution@ @accepted code@ @details@ @description@ 现有一个字符串 S。 Tiffany 将从中划分出 na 个子串作为 A 类串,第 i 个 Ai = S[la[i]...ra[i]]。 Yazid 将从中划分出 nb 个子串作为 B 类串,第 i 个 Bi = S[lb[i]...rb[i]]。 给定 m 组支配关系 (x, y),表示第 x 的 A 类串支配第 y 的 B 类串。 请使用任意多个 A 类串拼接起来得到最长的目标串 T,满足对于两个相邻的 A 类串,前一个 A 类串支配的某个 B 类串是后一个 A 类串的前缀。 如果无限长,输出 -1。 输入格式 从标准输入读入数据。 单个测试点中包含多组数据,输入的第一行包含一个非负整数 T 表示数据组数。接下来依次描述每组数据,对于每组数据: 第 1 行一个只包含小写字母的字符串 S。 第 2 行一个非负整数 na,表示 A 类串的数目。接下来 na 行,每行 2 个用空格隔开的整数。 这部分中第 i 行的两个数分别为 la[i], ra[i],描述第 i 个 A 类串。 保证 1 <= la[i] <= ra[i] <= |S|。 接下来一行一个非负整数 nb,表示 B 类串的数目。接下来 nb 行,每行 2 个用空格隔开的整数。