MongoDB - 图像的REST API体系结构(MongoDB - REST API Architecture For Images)
我在MONGODB的RAW BINARY DATA中有成千上万的图像(尺寸小于16MB),其JSON元数据来自小卫星(BSON文档)的日期,时间,位置等。 我必须制作REST API,它可以用各自的元数据查询图像。 以下事项需要在观察下进行。
数据= 数据截图
- 用户将根据时间,地点等,使用RestAPI查询元数据。
- 服务器将通过查询和DO图像处理从“无提示”中获取请求并返回图像
- 图像处理将在服务器端完成。
- 请求的图像将通过GET请求通过RESTAPI从服务器传输到客户端。
注意:请看附加图片以获取数据的想法。
使用的工具:数据库= MongoDB
问题
- 哪种服务器端编程语言更可行? PHP,Python或Node.js?
- 我在这种情况下如何做图像处理? 使用PHP,Python或Node.js上的库?
- 使用哪种技术为MongoDB制作最适合二进制数据和图像的REST API。
- 图像如何从服务器传输到客户端,即在二进制数据中。 然后在客户端呈现。
I have thousands of Images (wihch are less then 16MB in size) in RAW BINARY DATA in MONGODB with its Meta-Data in JSON as Date, Time, Location etc from the Small Satellite (BSON Documents). I have to make REST API which can query the Images with its respective Meta-Data. Following things needs to be taken under observation.
Data = Data Screenshot
- User's will query the Meta-Data with RestAPI, based on time, location etc.
- Server will get the Request from Cilent with Query and DO Image-Processing and Returns the Images
- Image Processing will be done on Server Side.
- Requested Images will travel through RESTAPI from Server to Client with the GET Request.
NOTE : Just see the Attached Picture to Get the Idea of the DATA.
Tools Used : Data-Base = MongoDB
Questions
- Which Server Side Programming Language is More feasible? PHP, Python or Node.js?
- How I could do Image-Processing in this scenario? With Libraries on PHP, Python or Node.js?
- Which Technology to be Used for making REST API for MongoDB which is best with Binary Data and Images.
- How Images will travel from Server to client i-e In binary data. and then Renders at Client Side.
原文:https://stackoverflow.com/questions/41244990
最满意答案
编辑:其实,我不再确定。 几个版本后来,似乎GLFW不再适用于OS X上的GHCi。
事实证明,GLFW + OpenGL满足所有四个要求!
- 你需要用
ghci -framework Carbon
调用ghci。- 你需要
EnableGUI.hs
文件,你可以在这里获得。 请注意,您无法将其加载到GHCi中,您必须首先将其加密。- OpenGL有一个2D投影模式,可以绘制线条和多边形。
- 位图可以作为纹理加载并放在多边形上。
这是一个小例子,它将一个位图放到屏幕上。 对位图有一些限制:它的尺寸必须是2的幂(这里是256),它必须是一个
.tga
文件(这里是"Bitmap.tga"
)。 但是既然支持透明度,这不是什么大问题。你应该可以多次呼叫
main
问题。 关键是你不应该调用GLFW.terminate
。import Graphics.Rendering.OpenGL as GL import qualified Graphics.UI.GLFW as GLFW import Graphics.Rendering.OpenGL (($=)) import Control.Monad import EnableGUI main = do enableGUI GLFW.initialize -- open window GLFW.openWindow (GL.Size 400 400) [GLFW.DisplayAlphaBits 8] GLFW.Window GLFW.windowTitle $= "Bitmap Test" -- enable alpha channel GL.blend $= GL.Enabled GL.blendFunc $= (GL.SrcAlpha, GL.OneMinusSrcAlpha) -- set the color to clear background GL.clearColor $= GL.Color4 0.8 0.8 0.8 0 -- set 2D orthogonal view inside windowSizeCallback because -- any change to the Window size should result in different -- OpenGL Viewport. GLFW.windowSizeCallback $= \ size@(GL.Size w h) -> do GL.viewport $= (GL.Position 0 0, size) GL.matrixMode $= GL.Projection GL.loadIdentity GL.ortho2D 0 (realToFrac w) (realToFrac h) 0 render <- initialize loop render GLFW.closeWindow loop render = do -- draw the entire screen render -- swap buffer GLFW.swapBuffers -- check whether ESC is pressed for termination p <- GLFW.getKey GLFW.ESC unless (p == GLFW.Press) $ do -- sleep for 1ms to yield CPU to other applications GLFW.sleep 0.001 -- only continue when the window is not closed windowOpenStatus <- GLFW.getParam GLFW.Opened unless (windowOpenStatus == False) $ loop render -- rendering initialize = do -- load texture from file GL.texture GL.Texture2D $= Enabled [textureName] <- GL.genObjectNames 1 GL.textureBinding GL.Texture2D $= Just textureName GL.textureFilter GL.Texture2D $= ((GL.Nearest, Nothing), GL.Nearest) GLFW.loadTexture2D "Bitmap.tga" [] return $ do GL.clear [GL.ColorBuffer] GL.renderPrimitive GL.Quads $ do GL.texCoord $ texCoord2 0 0 GL.vertex $ vertex3 (0) 256 0 GL.texCoord $ texCoord2 0 1 GL.vertex $ vertex3 (0) (0) 0 GL.texCoord $ texCoord2 1 1 GL.vertex $ vertex3 256 (0) 0 GL.texCoord $ texCoord2 1 0 GL.vertex $ vertex3 256 256 0 -- type signatures to avoid ambiguity vertex3 :: GLfloat -> GLfloat -> GLfloat -> GL.Vertex3 GLfloat vertex3 = GL.Vertex3 texCoord2 :: GLfloat -> GLfloat -> GL.TexCoord2 GLfloat texCoord2 = GL.TexCoord2 color3 :: GLfloat -> GLfloat -> GLfloat -> GL.Color3 GLfloat color3 = GL.Color3
这里有一个示例位图(您需要将其转换为
.tga
)。EDIT: Actually, I'm no longer sure. Several versions later, it seems that GLFW no longer works in GHCi on OS X.
It turns out that GLFW+OpenGL fulfills all four requirements!
- You need to invoke ghci with
ghci -framework Carbon
.- You need the
EnableGUI.hs
file, which you can get here. Note that you can't load it right into GHCi, you have to comiple it, first.- OpenGL has a 2D projection mode where you can draw lines and polygons.
- Bitmaps can be loaded as textures and put on polygons.
Here is a small example that puts a bitmap onto the screen. There are some restrictions on the bitmap: its dimensions must be a power of two (here 256) and it must be a
.tga
file (here"Bitmap.tga"
). But since transparency is supported, this is not much of a problem.You should be able to call
main
multiple times without problem. The key point is that you should not callGLFW.terminate
.import Graphics.Rendering.OpenGL as GL import qualified Graphics.UI.GLFW as GLFW import Graphics.Rendering.OpenGL (($=)) import Control.Monad import EnableGUI main = do enableGUI GLFW.initialize -- open window GLFW.openWindow (GL.Size 400 400) [GLFW.DisplayAlphaBits 8] GLFW.Window GLFW.windowTitle $= "Bitmap Test" -- enable alpha channel GL.blend $= GL.Enabled GL.blendFunc $= (GL.SrcAlpha, GL.OneMinusSrcAlpha) -- set the color to clear background GL.clearColor $= GL.Color4 0.8 0.8 0.8 0 -- set 2D orthogonal view inside windowSizeCallback because -- any change to the Window size should result in different -- OpenGL Viewport. GLFW.windowSizeCallback $= \ size@(GL.Size w h) -> do GL.viewport $= (GL.Position 0 0, size) GL.matrixMode $= GL.Projection GL.loadIdentity GL.ortho2D 0 (realToFrac w) (realToFrac h) 0 render <- initialize loop render GLFW.closeWindow loop render = do -- draw the entire screen render -- swap buffer GLFW.swapBuffers -- check whether ESC is pressed for termination p <- GLFW.getKey GLFW.ESC unless (p == GLFW.Press) $ do -- sleep for 1ms to yield CPU to other applications GLFW.sleep 0.001 -- only continue when the window is not closed windowOpenStatus <- GLFW.getParam GLFW.Opened unless (windowOpenStatus == False) $ loop render -- rendering initialize = do -- load texture from file GL.texture GL.Texture2D $= Enabled [textureName] <- GL.genObjectNames 1 GL.textureBinding GL.Texture2D $= Just textureName GL.textureFilter GL.Texture2D $= ((GL.Nearest, Nothing), GL.Nearest) GLFW.loadTexture2D "Bitmap.tga" [] return $ do GL.clear [GL.ColorBuffer] GL.renderPrimitive GL.Quads $ do GL.texCoord $ texCoord2 0 0 GL.vertex $ vertex3 (0) 256 0 GL.texCoord $ texCoord2 0 1 GL.vertex $ vertex3 (0) (0) 0 GL.texCoord $ texCoord2 1 1 GL.vertex $ vertex3 256 (0) 0 GL.texCoord $ texCoord2 1 0 GL.vertex $ vertex3 256 256 0 -- type signatures to avoid ambiguity vertex3 :: GLfloat -> GLfloat -> GLfloat -> GL.Vertex3 GLfloat vertex3 = GL.Vertex3 texCoord2 :: GLfloat -> GLfloat -> GL.TexCoord2 GLfloat texCoord2 = GL.TexCoord2 color3 :: GLfloat -> GLfloat -> GLfloat -> GL.Color3 GLfloat color3 = GL.Color3
Here an example bitmap (which you need to convert to
.tga
).
相关问答
更多-
编辑:其实,我不再确定。 几个版本后来,似乎GLFW不再适用于OS X上的GHCi。 事实证明,GLFW + OpenGL满足所有四个要求! 你需要用ghci -framework Carbon调用ghci。 你需要EnableGUI.hs文件,你可以在这里获得。 请注意,您无法将其加载到GHCi中,您必须首先将其加密。 OpenGL有一个2D投影模式,可以绘制线条和多边形。 位图可以作为纹理加载并放在多边形上。 这是一个小例子,它将一个位图放到屏幕上。 对位图有一些限制:它的尺寸必须是2的幂(这里是256 ...
-
在最新的haskell模式下跟随事物模式匹配: :set prompt "λ> " Following thing pattern matches in the latest haskell-mode: :set prompt "λ> "
-
尽管stack ghci工作,但由于缺少包,堆栈构建失败(Stack build fails due to missing package although stack ghci works)[2021-10-16]
这很可能是因为您将bytestring添加到库的build-depends中,而不是可执行文件。 避免需要为不同节重复这些依赖关系的一个选项是使用hpack作为包描述格式。 This is likely because you added bytestring to the build-depends of the library, not the executable. One option to avoid needing to repeat these dependencies for the dif ... -
Haskell / GHCI中的别名(Aliases in Haskell/GHCI)[2022-02-17]
:def命令可以做到这一点: :def sbh const $ return ":cd Desktop/Sandbox/Haskell" 正如你所看到的,它比一个替换字符串稍微复杂一点:它需要一个类型为String -> IO String的Haskell函数,新定义的命令将其应用于其参数字符串以计算要运行的新命令。 然后在GHCI :sbh来援引。 The :def command can do this: :def sbh const $ return ":cd Desktop/Sandbox/Has ... -
有一个名为GHCLive的Summer of Code项目,看起来与你想要的完全一样。 相当令人惊讶的是,没有人真正在谈论它。 我希望他们是。 There is a Summer of Code project called GHCLive, which looks exactly like what you want. Quite surprisingly, no one is really talking about it. I wish they were.
-
这是因为Windows上没有getch 。 getch是POSIX,POSIX已在Windows上弃用。 它仍然存在,但函数已被移动到不同的命名空间(以将根命名空间释放到用户程序)。 正如您所看到的,MSDN表示不推荐使用getch https://msdn.microsoft.com/en-us/library/ms235446.aspx并使用_getch代替。 import Control.Monad import Data.Char import Foreign.C getCh :: IO Char ...
-
Haskell,限制GHCI内存(Haskell, Limit GHCI memory)[2023-01-01]
stack ghci +RTS -M256m -K256m 这不是设置GHCi的RTS选项,而是stack 。 毕竟, stack也是用Haskell编写的,因此也可以使用RTS选项。 使用--ghci-options可以为GHCi提供其他选项: stack ghci --ghci-options="+RTS -M256m -K256m -RTS" 由于stack为GHCi提供了更多选项,因此关闭-RTS是必需的。 stack ghci +RTS -M256m -K256m That's not se ... -
阅读ghci 。 去引用 在GHCi提示符下接受的语句的语法与Haskell do表达式中的语句的语法完全相同。 但是,这里没有monad重载:在提示符下键入的语句必须在IO monad中。 当您在ghci中编写任何内容时,基本上您都在IO Monad中。 Read about ghci. To quote The syntax of a statement accepted at the GHCi prompt is exactly the same as the syntax of a statemen ...
-
Haskell GHCi - 使用getContents在stdin上使用EOF字符(Haskell GHCi - Using EOF character on stdin with getContents)[2023-06-20]
getContents == hGetContents stdin 。 不幸的是, hGetContents其句柄标记为(半)关闭,这意味着任何尝试再次从stdin读取的操作都将失败。 只需读取空行或其他标记,从不关闭stdin就足够了吗? takeWhileM :: Monad m => (a -> Bool) -> [m a] -> m [a] takeWhileM p (ma : mas) = do a <- ma if p a then liftM (a :) $ tak ... -
在GHCi中,您可以使用:{ :}表示多行表达式。 例如: Prelude> :{ Prelude| let bar = ["a", Prelude| "b", Prelude| "c"] Prelude| :} :{ :}阻止GHCi在下一个换行符之后评估你的代码并向你抛出错误,因为它不是一个完整的表达式。 另请注意,顶级定义不需要let 。 在普通的Haskell源文件中,您只需编写: bar = ["a", "b", "c"] ...