美好时光!
我的Android应用程序试图使用通常的Java组合读取简单的文本文件
FileReader fr = new FileReader("file:///android_asset/example.txt");
BufferedReader bfr = new BufferedReader(fr);
Run Code Online (Sandbox Code Playgroud)
但是,无论我做什么,我都会找到File not Found exeption,尽管此目录中还有另一个html文件,并且正确显示在WebView中.
所以,我的问题是:
FileReader可用于简单阅读文本文件或我必须使用InputStream?
首先,我知道如何更新 Bare Repository。我想知道为什么当我当前的存储库bare和我fetch来自远程存储库时,git 创建,remote (tracking) branches??? 除了我从 fetch 时origin?
我试过这个实验:
我在当前目录中有三个目录:origin,bare_clone和remote. 现在:
$ cd ./origin
$ git init
$ cat > 1
^Z
$ git add 1
$ git commit -m "add 1 in initial commit"
$ cd ../bare_clone
$ git clone --bare ../origin
$ cd ../remote
$ git init
$ cat > 1
^Z
$ git add 1
$ git git commit -m …Run Code Online (Sandbox Code Playgroud) 在Git-config中,您可以看到:
简单 - 在集中式工作流程中,像上游一样工作,如果上游分支的名称与本地分支不同,则会增加安全性以拒绝推送.
当推送到与您通常拉出的遥控器不同的遥控器时,请作为当前工作.
所以Git必须那样工作之间做出选择upstream或者current.但如何Git检测工作流程类型?是否Git觉得工作流程是centralized,如果明白我们想要一个沟通bare信息库?
它可能是一个简单/愚蠢的问题,但我在opencv(android)中有转换问题.
我的目标是从两个连续的图像中计算出相应匹配的基本矩阵.
我编程到目前为止(和工作):
detector.detect(actImg, actKP);
detector.detect(prevImg, prevKP);
descExtractor.compute(prevImg, prevKP, descriptorPrev);
descExtractor.compute(actImg, actKP, descriptorAct);
descMatcher.match(descriptorPrev, descriptorAct, matches);
Features2d.drawMatches(prevImg, prevKP, actImg, actKP,matches, mRgba);
Run Code Online (Sandbox Code Playgroud)
匹配的类型为MatOfDMatch.
现在我将从相互匹配的点中计算出基本矩阵.因此,我必须知道在第二张图像(actKP)中找到第一张图像(prevKP)中的哪些关键点.
Mat fundamental_matrix = Calib3d.findFundamentalMat(nextPts, prevPts, Calib3d.FM_RANSAC,3, 0.99);
Run Code Online (Sandbox Code Playgroud)
第一个问题:如何将MatOfKeyPoints提取/转换为MatOfPoint2f(它们可以传递给findFundamentalMatrix)
第二个问题:如何只将匹配的关键点传递给函数findFundamentalMatrix.这是一个很好的方法吗?
非常感谢advace!
编辑
非常感谢您的详细回复!我把你的代码写成两个函数:
private MatOfPoint2f getMatOfPoint2fFromDMatchesTrain(MatOfDMatch matches2,
MatOfKeyPoint prevKP2) {
DMatch dm[] = matches2.toArray();
List<Point> lp1 = new ArrayList<Point>(dm.length);
KeyPoint tkp[] = prevKP2.toArray();
for (int i = 0; i < dm.length; i++) {
DMatch dmm = dm[i];
if (dmm.trainIdx < tkp.length)
lp1.add(tkp[dmm.trainIdx].pt);
}
return new MatOfPoint2f(lp1.toArray(new Point[0]));
} …Run Code Online (Sandbox Code Playgroud) 我有一个Generic类.它看起来像这样:
public class DataConverter<T> implements Converter<T> {
@Override
public T convert(Class<T> type, Object value) {
if ((type.equals(String.class)) && ... ) {
return conevertDataToJSONString((Data) value);
}
...
}
private T conevertDataToJSONString(Data data) {
String value = gson.toJson(data);
return (T) value; // << Type safety: Unchecked cast from String to T
}
...
}
Run Code Online (Sandbox Code Playgroud)
显然conevertDataToJSONString只有在TString类型时调用的方法.但是有一个警告:
类型安全:从String到T的未选中强制转换
有没有办法解决这个问题而不使用SuppressWarnings:
@SuppressWarnings( "未登记")
方法之前?
我的计算机上已经有一个 Git 存储库。我想在我的计算机中为它设置一个远程存储库,例如在/path/to/remote.
所以我曾经git init启动一个空的存储库。然后我使用了这个命令:
$ git remote add test "file:///path/to/remote/.git/"
Run Code Online (Sandbox Code Playgroud)
然后尝试:
$ git push -u test --all
Run Code Online (Sandbox Code Playgroud)
但结果错误:
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: …Run Code Online (Sandbox Code Playgroud) git ×3
android ×2
filereader ×1
git-push ×1
git-workflow ×1
java ×1
opencv ×1
repository ×1
type-safety ×1
types ×1