使用InputStream结束的好处是什么InputStreamReader,反之亦然.
这是一个实际的例子InputStream:
InputStream input = new FileInputStream("c:\\data\\input-text.txt");
int data = input.read();
while(data != -1) {
//do something with data...
doSomethingWithData(data);
data = input.read();
}
input.close();
Run Code Online (Sandbox Code Playgroud)
这是一个使用InputStreamReader的例子(很明显在InputStream的帮助下):
InputStream inputStream = new FileInputStream("c:\\data\\input.txt");
Reader reader = new InputStreamReader(inputStream);
int data = reader.read();
while(data != -1){
char theChar = (char) data;
data = reader.read();
}
reader.close();
Run Code Online (Sandbox Code Playgroud)
Reader是否以特殊方式处理数据?
试着让我了解i/oJava中的整个流数据方面.
我正在使用Android Studio开发Android应用程序.但是我在Android Studio中听说最好只在一个应用程序(每个应用程序一个项目)中只有一个应用程序,如果这是正确的,那么为许多项目打开许多帧将是非常浪费的.但是当我搜索时,我发现了
现在,如果这是真的,这意味着Android Studio也可以支持多应用程序项目.如果是,那么,Android Studio中的每个应用程序都是独立的,就像在Eclipse中一样(即它们不会通过共享任何文件或设置来互相干扰)?或者我们可以在一个项目中拥有许多应用程序吗?如果我们可以那么有任何意义吗?
谢谢!
我想将以下MIME类型添加到运行的站点Apache:
<mime-mapping>
<extension>jnlp</extension>
<mime-type>application/x-java-jnlp-file</mime-type>
</mime-mapping>
Run Code Online (Sandbox Code Playgroud)
那是Tomcat格式.
我在共享主机上,所以我只能创建一个.htaccess文件.有人请指定这样一个文件的完整内容吗?
我在Java中使用OpenCV 3.0(最新版本),但是当我使用SURF算法或SIFT算法时它不起作用并抛出Exception,它说: OpenCV Error: Bad argument (Specified feature detector type is not supported.) in cv::javaFeatureDetector::create
我用谷歌搜索了,但是给出这类问题的答案并没有解决我的问题.如果有人知道这个问题,请告诉我.
提前致谢!
更新:第三行中的代码抛出异常.
Mat img_object = Imgcodecs.imread("data/img_object.jpg");
Mat img_scene = Imgcodecs.imread("data/img_scene.jpg");
FeatureDetector detector = FeatureDetector.create(FeatureDetector.SURF);
MatOfKeyPoint keypoints_object = new MatOfKeyPoint();
MatOfKeyPoint keypoints_scene = new MatOfKeyPoint();
detector.detect(img_object, keypoints_object);
detector.detect(img_scene, keypoints_scene);
Run Code Online (Sandbox Code Playgroud) 我使用Eclipse IDE在Java中使用OpenCV 3.0,但我想将Javadoc附加到OpenCV jar以便轻松阅读方法和参数用法.在我使用OpenCV 2.4.10之前,它的源代码文档很好,并且很容易知道方法和参数.但是现在OpenCV 3源代码中没有任何文档工具.
如果有人知道这一点,请告诉我如何为OpenCV 3.0附加Javadoc.
提前致谢!!
我想知道为什么在下面的C++代码中,复制构造函数被调用25次10次迭代?
如果它是10那么好10/10 = 1,或者20/10 = 2,或者30/10 = 3,但是25/10 = 2.5?这.5意味着什么?
标题:
class Person
{
public:
Person(std::string name, int age);
Person(const Person &person);
const std::string &getName() const;
int getAge() const;
private:
std::string name;
int age;
};
Run Code Online (Sandbox Code Playgroud)
资源:
Person::Person(string name, int age) : name(std::move(name)), age(age)
{}
Person::Person(const Person &person)
{
this->name = person.name;
this->age = person.age;
static int count = 0;
count++;
cout << ">>Copy-Person::Person(Person &person) " << count << endl;
} …Run Code Online (Sandbox Code Playgroud) 我可以通过使用VideoCapture和读取帧来打开 RTSP 视频流。
它是 RTSP 流的 URL:
rtsp://username:password@xxx.xxx.xxx.xxx:554/Streaming/Channels/102
Run Code Online (Sandbox Code Playgroud)
现在我想将图像/mat 发送/写回输出流(通过 LAN 网络的 RTMP 流)
我已经设置了 NGINX 的 RTMP 服务器,为了测试,我下载了FFMPEG,当运行以下命令(在 CMD 中)时,它运行良好,并成功地将流读取和写入 NGINX 服务器。
ffmpeg -i rtsp://username:password@xxx.xxx.xxx.xxx:554/Streaming/Channels/102 -vcodec copy -acodec copy -f flv rtmp://xxx.xxx.xxx.xxx:1395/mylive/test
Run Code Online (Sandbox Code Playgroud)
现在如果我把这个rtmp://xxx.xxx.xxx.xxx:1395/mylive/testURL放在video标签上HTML,那么视频就可以打开了。
所以问题是如何在处理后从我的代码中通过 RTMP (NGINX) 推送图像?
任何建议。提前致谢!!
编辑:
我使用VideoWriter类作为以下方式,但没有人工作:
VideoWriter writer = new VideoWriter();
writer.open("rtmp://xxx.xxx.xxx.xxx:1395/mylive/test", CAP_FFMPEG, 0, 25,
new Size(640, 480));
//writer.open("ffmpeg -vcodec copy -acodec copy -f flv
//rtmp://xxx.xxx.xxx.xxx:1395/mylive/test", CAP_FFMPEG, 0, 25, new Size(640,
//480)); …Run Code Online (Sandbox Code Playgroud) 我想将字节数组转换为Mat对象,但它会抛出
java.lang.UnsupportedOperationException: Provided data element number (60181) should be multiple of the Mat channels count (3)
at org.opencv.core.Mat.put(Mat.java:992)
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
byte[] bytes = FileUtils.readFileToByteArray(new File("aaa.jpg"));
Mat mat = new Mat(576, 720, CvType.CV_8UC3);
//Imgcodecs.imencode(".jpg", mat, new MatOfByte(bytes));
mat.put(0, 0, bytes);
Run Code Online (Sandbox Code Playgroud)
我尝试了很多方法,也搜索了很多,但没有找到任何解决方案.
注意:我知道Imgcodecs.imread("aaa.jpg");并且
BufferedImage img = ImageIO.read(new ByteArrayInputStream(byteArray));
Mat mat = new Mat(img.getHeight(), img.getWidth(), CvType.CV_8UC3);
mat.put(0, 0, ((DataBufferByte) img.getRaster().getDataBuffer()).getData());
Run Code Online (Sandbox Code Playgroud)
但我希望直接将字节数组转换为Mat,而无需任何额外的过程来加快处理时间.
提前致谢!
基本上我在下面的代码中有两个问题:
const char *x = "abc";
const char *y = "def";
char *res = (char*)malloc(0);
char *z = res;
while (*z++ = *x++);
z--; // remove \0
while (*z++ = *y++);
printf("%s\n", res); // output: abcdef
free(res);
Run Code Online (Sandbox Code Playgroud)
此代码的目的是在一个中添加两个字符串.但是这条线while (*z++ = *x++);如何起作用boolean 1/0,为什么我甚malloc(0);至将它设置为零它也运行良好没有任何问题?
我想生成一个 SO 文件及其对应的 Java 接口,以便在另一个项目中使用它。
到目前为止我做了什么:
我在 Android Studio 2.3.3(2017-08-09 的最新版本)中创建了一个带有“Include C++ support”的项目,并编写了一些 C/C++ 代码并编译它,当我运行该程序时,它被成功调用并返回一个“来自 JNI 的你好”字符串。
所以在那之后,我查看了生成.so文件的输出,但在那里我没有找到这个文件。之后,我在输出文件夹中找到了生成的 APK 文件,当我解压缩它时,我在里面找到了这些文件夹,它们都包含.so文件:
现在的问题是,如何将这些.so文件使用到另一个项目中,因此我在互联网上搜索了很多,但不幸的是,我没有找到任何解决方案,他们提到的解决方案都是在文件夹中创建一个文件main夹项目名称,jniLibs并在修改 Gradle 文件后等等......,但没有人在工作。
这里我想知道如何添加.so文件和对应的Java接口在项目中使用呢?
现在我在尝试调用 .so 文件中的 JNI 函数时进入新项目时出现错误。