客户端-服务器应用程序。客户端(手机)向服务器发送一个2GB以上的大文件,客户端可能没电了,但是当手机和应用程序打开时,文件应该继续发送。问题:如何在背面实现?
Санаев's questions
客户端向服务器发送图像。保存图像的目录在配置中注册在服务器上:
spring.servlet.multipart.enabled=true
spring.servlet.multipart.location=C:/images
代码大大减少(离开主要的),图像的新名称在这里形成,并保存到配置目录中。
public URI uploadImage(MultipartFile image) throws IOException {
String originalFilename = image.getOriginalFilename();
String extension = getExtension(originalFilename);
File file = new File(UUID.randomUUID().toString() + extension);
image.transferTo(file);
return file.toURI();
}
我尝试返回图像的URI,它返回:项目路径+图像名称,但它应该是配置+图像名称的路径。
需要您的帮助如何解决?
您需要在 postgres 中四舍五入,因此:
2019-07-24 11:31:22 -> 2019-07-24 12:00:00
2019-07-24 11:29:22 -> 2019-07-24 11:00:00
2019-07-24 11:59:22 -> 2019-07-24 12:00:00
我开始学习 Flask,在第一节课上我就遇到了错误:)
下面的代码:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return 'this is a Flask'
app.run('127.0.0.1:8200', debug=True)
日志:
C:\Users\gibki\AppData\Local\Programs\Python\Python37\python.exe C:/Users/gibki/PycharmProjects/image-similarity-deep-ranking1/app.py
* Serving Flask app "app" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: on
Traceback (most recent call last):
File "C:/Users/gibki/PycharmProjects/image-similarity-deep-ranking1/app.py", line 11, in <module>
app.run('127.0.0.1:8200', debug=True)
File "C:\Users\gibki\AppData\Roaming\Python\Python37\site-packages\flask\app.py", line 944, in run
run_simple(host, port, self, **options)
File "C:\Users\gibki\AppData\Roaming\Python\Python37\site-packages\werkzeug\serving.py", line 987, in run_simple
s.bind(server_address)
socket.gaierror: [Errno 11001] getaddrinfo failed
阅读文章https://medium.com/@akarshzingade/image-similarity ... 遇到了实现https://github.com/akarshzingade/image-similarity-deep-ranking但它需要下载三元组(我做到了) 并填写 (tripletSampler.py)
parser = argparse.ArgumentParser(description='Optional app description')
parser.add_argument('--input_directory',
help='A argument for input directory')
parser.add_argument('--output_directory',
help='A argument for output directory')
parser.add_argument('--num_pos_images',
help='A argument for the number of Positive images per Query image')
parser.add_argument('--num_neg_images',
help='A argument for the number of Negative images per Query image')
但我不明白该怎么做。告诉?
在启动时它会写入一个错误:
运行“未命名 (1)”时出错:在模块的 GWT Facet 设置中未正确指定 GWT SDK 路径
尝试通过配置“添加框架支持”添加 gwt,但没有 gwt。请告诉我如何解决它。
告诉我如何制作它,以便它不会按坐标向我显示一个点,而是建立一条从当前位置到纬度、经度的路线。目前我已经这样做了:
private void showMap(Uri geoLocation) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(geoLocation);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}
我需要用户点击按钮,然后他被要求选择打开哪个地图,之后:从当前位置到所选点,他将建立一条路线
Uri 是这样生成的:
Uri.parse("geo:" + latitude + "," + longitude);
有现成的图书馆吗?
您可以使用以下方法查找手机上所有已安装的应用程序:getPackageManager().getInstalledPackages(0)
我可以找到手机上安装的地图应用程序。现在如何提示用户选择其中之一?
ConcurrentModificationExceptionHello在此行for (Transaction t : c.getTransactions())(第 64 行)上抛出 Exception 2 次迭代。我理解错误的本质——它发生在迭代器的元素在循环中被删除时。试图将 remove 更改为removeIF,但同样的错误。这是一个独特的问题,因为它发生在满足其解决方案的所有要求时。
private static void iteration() {
Integer n = 1;
Integer k = 1;
Double maxProfit;
Integer clusterInd;
while (k > 0) {
System.out.println("Итерация " + n);
n++;
k = 0;
for (int i=0;i<clusters.size();i++) {
Cluster c = clusters.get(i);
for (Transaction t : c.getTransactions()) {//ошибку кидает здесь на 2 итерации
maxProfit = profit();
clusterInd = -1;
c.deleteTransaction(t);
int j = 0;
for (Cluster cl : clusters) {
if (j != i) {
cl.addTransaction(t);
Double p = profit();
if (p > maxProfit) {
maxProfit = p;
clusterInd = j;
}
cl.deleteTransaction(t);
}
j++;
}
if (clusterInd == -1){
clusters.get(i).addTransaction(t);
}else {
k++;
clusters.get(clusterInd).addTransaction(t);
}
}
}
}
System.out.println(k);
}
删除事务的函数:
public void deleteTransaction(Transaction m) {
if (this.count > 0) {
String[] trans = m.getTrans();
for (String s : trans) {
this.square--;
if (freq.containsKey(s)) {
if (freq.get(s) > 0) {
this.freq.put(s, freq.get(s) - 1);
if (this.freq.get(s) == 0) {
this.width--;
freq.entrySet().removeIf(entry -> entry.getKey().equals(s));
}
}
}
}
this.count--;
if (this.count > 0) {
this.height = (double) this.square / this.width;
} else {
this.height = 0.0;
}
transactions.removeIf(m::equals);
}
}
日志:
Exception in thread "main" java.util.ConcurrentModificationException
at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:939)
at java.base/java.util.ArrayList$Itr.next(ArrayList.java:893)
at com.lab6.ClopeAlgorithm.iteration(ClopeAlgorithm.java:64)
at com.lab6.ClopeAlgorithm.main(ClopeAlgorithm.java:96)
由于某种原因,在平移坐标时,矩阵对我来说是\u200b\u200b View:
private Vector3f getCoord(MouseInput mouseInput, float z) {
int wdwWitdh = 800;
int wdwHeight = 800;
Vector2d mousePos = mouseInput.getCurrentPos();
float x = (float) (2 * mousePos.x) / (float) wdwWitdh - 1.0f;
float y = 1.0f - (float) (2 * mousePos.y) / (float) wdwHeight;
Matrix4f invProjectionMatrix = new Matrix4f();
Matrix4f invViewMatrix = new Matrix4f();
Vector4f tmpVec = new Vector4f();
invProjectionMatrix.set(p);
invProjectionMatrix.invert();
tmpVec.set(x, y, z, 1.0f);
tmpVec.mul(invProjectionMatrix);
tmpVec.z = z;
tmpVec.w = 0.0f;
invViewMatrix.set(view);
invViewMatrix.invert();
tmpVec.mul(invViewMatrix);
return new Vector3f(tmpVec.x, tmpVec.y, z);
}
光束渲染:
private void rectangleRay(MouseInput mouseInput) {
glUseProgram(rayProgram);
FloatBuffer vi = BufferUtils.createFloatBuffer(16);
view.get(vi);
glUniformMatrix4fv(glGetUniformLocation(rayProgram, "projectionMatrix"), false, pMatrix);
glUniformMatrix4fv(glGetUniformLocation(rayProgram, "modelViewMatrix"), false, vi);
glBindVertexArray(vaoRay);
glBindBuffer(GL_ARRAY_BUFFER, rayBuffer);//pointbuffer-камера, точка помещаем ее в буффер
if (originRay != null && !mouseInput.isLeftButtonPressed()) {
glBufferData(GL_ARRAY_BUFFER, BufferUtils.createFloatBuffer(3 * 2 * Float.BYTES).put(new float[]{
originRay.x, originRay.y, pz, originRay.x, originRay.y, cz
}).rewind(), GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, 0);
glEnableVertexAttribArray(0);
originRay = null;
}
drawLine(2);
}
查看开头的坐标:
Vector3f cameraPosition = new Vector3f(0, 0, 1);
FloatBuffer vMatrix = BufferUtils.createFloatBuffer(16);
view = new Matrix4f();
view.lookAt(cameraPosition.x, cameraPosition.y, cameraPosition.z,
0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f).get(vMatrix);
滚动时如何更改相机坐标:
wnd.setKeyListener((key, scancode, action) -> { Vector3f whatToMove = render.cameraPosition; float step = 0.1f;
switch (key) {
case GLFW_KEY_W:
whatToMove.add(0, step, 0);
break;
case GLFW_KEY_S:
whatToMove.sub(0, step, 0);
break;
case GLFW_KEY_A:
whatToMove.sub(step, 0, 0);
break;
case GLFW_KEY_D:
whatToMove.add(step, 0, 0);
break;
case GLFW_KEY_Q:
whatToMove.sub(0, 0, step);
break;
case GLFW_KEY_E:
whatToMove.add(0, 0, step);
break;
}
在第一次开始时,正交投影中的光线被投影到一个点(正确),然后我开始旋转相机,改变视图矩阵。
有一个包含这些行的文件:
土豆卷心菜
牛奶面包
面包洋葱
我想得到List<List<>>,即工作表应该包含该行的单词。
试图这样做:
Files.lines(Paths.get(ReadFile.class.getResource(path).toURI()), StandardCharsets.UTF_8)
.flatMap(s->Arrays.stream(s.split(" ")))
.filter(s->!s.isEmpty())
.collect(Collectors.toList());
但这就是文件中所有单词的编写方式。需要在流上实现这一点。
流中有这样的警告:“ Unchecked call to filter as a member raw ...”,如何解决?
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
System.out.print("Введите слово: ");
String word = scn.nextLine();
String[] str = {"Масло", "Вода", "Дерево", "Помидор", "Сельдерей", "Кувшин"};
List wordList = Arrays.asList(str);
long countWord = wordList
.stream()
.filter(s -> s.equals(word))
.count();
if (countWord > 0) {
System.out.println("Слово найдено");
} else {
System.out.println("Слово не найдено");
}
}
有一个场景,在场景 obj 模型上。需要选择模型的多边形。
按下鼠标右键,然后围绕按下的点绘制一个矩形,在矩形的角上绘制选择性光线。您需要从模型中选择(涂上颜色)落入该区域的三角形。
我使用 LWJGL 和 JOML 库。我发现了这样的函数:unproject,它从屏幕坐标转换为世界坐标intersectRayPlane- 光线是否与多边形相交。
我制作了选择性光束(结果是 6 个平面)。现在有必要在这个截断的金字塔内的三角形上着色。你会如何建议这样做?告诉我不要告诉我几何,而是确切地告诉我如何在着色器中以编程方式完成它。给定:P矩阵,视图矩阵,Q=PV矩阵,模型M矩阵,平面顶点坐标(其中有8个origin(beam end坐标)和dir(不知道什么意思,用了unproject函数)) ,模型顶点坐标及其法线。
我找到了所有 6 个平截头体平面的abcd组件。接下来,我取一个点并测量到 6 个平截头体平面中的每一个平面的距离。如果距离为负,则该点不在截锥体内。下面是其中的着色器,很可能是一个错误:我传递给顶点着色器
vec4[6] planes - a b c d для 6 плоскостей.
out float[6] dis;- это расстояния, которые я передаю во фрагментный шейдер
#version 330
layout(location = 0) in vec3 vertexPos;
layout(location = 1) in vec3 normal;
layout (location = 2) in vec2 texCoord;
out float[6] dis;
out vec3 normal_modelspace;
out vec3 vertex_modelspace;
out vec2 TexCoord;
out vec4 vertexColor;
uniform mat4 P;
uniform mat4 V;
uniform mat4 M;
uniform vec4[6] planes;
void main() {
TexCoord = texCoord;
vertex_modelspace = (M * vec4(vertexPos.xyz, 1.0)).xyz;
vertexColor = vec4(0.5f, 0.0f, 0.0f, 1.0f);
gl_Position = P * V * vec4(vertex_modelspace.xyz, 1.0);
normal_modelspace = (M * vec4(normal.xyz, 1.0)).xyz;
vec3 EyeDirection_cameraspace = vec3(0,0,0) - (V * M * vec4(vertexPos,1)).xyz;
for(int i = 0;i<6;i++){
float denom = sqrt(planes[0].x * planes[0].x + planes[0].y * planes[0].y + planes[0].z * planes[0].z);
dis[i] = float((planes[0].x * vertex_modelspace.x + planes[0].y * vertex_modelspace.y + planes[0].z * vertex_modelspace.z + planes[0].w) / denom);
}
}
片段着色器 在这里我检查循环中点的距离,如果找到负值,则应该用颜色覆盖它。
#version 330 core
in vec3 normal_modelspace;
in vec3 vertex_modelspace;
in vec2 TexCoord;
in vec4 vertexColor;
in float[6] dis;
out vec4 color;
uniform vec3 light_worldspace;
uniform sampler2D ourTexture;
void main() {
vec3 n = normalize(normal_modelspace);
vec3 l = normalize(light_worldspace - vertex_modelspace);
float cosTheta = clamp( dot( n, l), 0,1 );
float ambient = 0.05;
int i=0;
while(i<6 && dis[i]<=0){
i++;
}
if(i==6){
color = texture(ourTexture, TexCoord);
}
else
color = vertexColor;
}
我正在阅读 Schildt 的书 Java 8,“引用静态方法”一章。
问题是关于类的MyStringOps——很明显,类是声明的,而不是接口,但出于某种原因,接口是写在书中的。这是错别字?还是我误解了什么?
// Продемонстрировать ссылку на статический метод
// Функциональный интерфейс для операций с символьными строками
interface StringFunc {
String func (String n);
}
// в этом интерфейсе определяется статический метод strReverse ()
class MyStringOps {
// Статический метод, изменяющий порядок
// следования символов в строке
static String strReverse (String str) {
String result = " " ;
int i;
for (i = str.length()- 1; i >= О; i--)
result += str.charAt (i) ;
return result;
}
}
class MethodRefDemo {
// В этом методе функциональный интерфейс указывается в качестве
// типа первого его параметра . Следовательно, ему может быть передан
// любой экземпляр этого интерфейса , включая и ссылку на ме тод
static StringstringOp (StringFunc sf, String s) {
return sf.func(s) ;
public static void main (String args[])
{
String inS tr = "Лямбда- выражения повышают эффективность Java ";
String out Str;
// Здесь ссылка на метод strRaverse () передается методу stringOp()
outStr = stringOp ( MyStringOps::strReverse, inStr);
System.out.println (" Иcxoднaя строка : "+ inStr);
System.out.println ("Oбpaщeннaя строка : "+ outStr);
}
}
我有一个具有以下值的 ArrayList:
{"*","12","24","52","*","35","3","*","3"}
我需要转换此工作表以获得这样的对象数组(分隔符 *):
{{"12","24","52"},{"35","3"},{"3"}}
我不是在流上写这个实现的。
告诉我,是否有可能在流上做到这一点?
有没有办法使用 java 9 或 java 8 来简化这个循环?
for (String s : list) {
if (s.indexOf("D") != -1) {
numberList.addAll(getDoubleFromString(s));
} else {
if (s.indexOf(".") != -1) {
numberList.add(new TypeSatellite(BigDecimal.valueOf(Double.valueOf(s))));
} else {
numberList.add(new TypeSatellite(Integer.valueOf(s)));
}
}
}
有这样一行6.356909871101D-04:如何将其转换为DoubleJava?尝试通过Double.parse,Double.valueOf但无济于事。
我目前正在学习 Java 8 和 JAVA 9 的流。问题是如何首先跳过END OF HEADER位置之后的文件行(文件的倒数第二行),然后计算每个值(剩余的数字)并且是可以在流上完成我的任务吗?
2.10 N: GPS NAV DATA RINEX VERSION / TYPE
teqc 2017Feb10 UNAVCO Archive Ops 20170418 19:33:16UTCPGM / RUN BY / DATE
9.2160D+04 -1.1469D+05 -1.3107D+05 7.2090D+05 ION BETA
9.313225746155D-10 3.552713678801D-15 233472 1930 DELTA-UTC: A0,A1,T,W
END OF HEADER
29 17 1 1 2 0 0.0 6.356909871101D-04-2.046363078989D-12 0.000000000000D+00
开始这样做:
try {
Files.lines(Paths.get("src/main/java/ab010010.17n"), StandardCharsets.UTF_8).// дальше что применять и множества методов?;
} catch (IOException e) {
e.printStackTrace();
}





