首页 \ 问答 \ MongoDB - 图像的REST API体系结构(MongoDB - REST API Architecture For Images)

MongoDB - 图像的REST API体系结构(MongoDB - REST API Architecture For Images)

我在MONGODB的RAW BINARY DATA中有成千上万的图像(尺寸小于16MB),其JSON元数据来自小卫星(BSON文档)的日期,时间,位置等。 我必须制作REST API,它可以用各自的元数据查询图像。 以下事项需要在观察下进行。

数据= 数据截图

  1. 用户将根据时间,地点等,使用RestAPI查询元数据。
  2. 服务器将通过查询和DO图像处理从“无提示”中获取请求并返回图像
  3. 图像处理将在服务器端完成。
  4. 请求的图像将通过GET请求通过RESTAPI从服务器传输到客户端。

注意:请看附加图片以获取数据的想法。

使用的工具:数据库= MongoDB

问题

  1. 哪种服务器端编程语言更可行? PHP,Python或Node.js?
  2. 我在这种情况下如何做图像处理? 使用PHP,Python或Node.js上的库?
  3. 使用哪种技术为MongoDB制作最适合二进制数据和图像的REST API。
  4. 图像如何从服务器传输到客户端,即在二进制数据中。 然后在客户端呈现。

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

  1. User's will query the Meta-Data with RestAPI, based on time, location etc.
  2. Server will get the Request from Cilent with Query and DO Image-Processing and Returns the Images
  3. Image Processing will be done on Server Side.
  4. 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

  1. Which Server Side Programming Language is More feasible? PHP, Python or Node.js?
  2. How I could do Image-Processing in this scenario? With Libraries on PHP, Python or Node.js?
  3. Which Technology to be Used for making REST API for MongoDB which is best with Binary Data and Images.
  4. How Images will travel from Server to client i-e In binary data. and then Renders at Client Side.

原文:https://stackoverflow.com/questions/41244990
更新时间:2022-04-16 13:04

最满意答案

编辑:其实,我不再确定。 几个版本后来,似乎GLFW不再适用于OS X上的GHCi。

事实证明,GLFW + OpenGL满足所有四个要求!

  1. 你需要用ghci -framework Carbon调用ghci。
  2. 你需要EnableGUI.hs文件,你可以在这里获得。 请注意,您无法将其加载到GHCi中,您必须首先将其加密。
  3. OpenGL有一个2D投影模式,可以绘制线条和多边形。
  4. 位图可以作为纹理加载并放在多边形上。

这是一个小例子,它将一个位图放到屏幕上。 对位图有一些限制:它的尺寸必须是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!

  1. You need to invoke ghci with ghci -framework Carbon.
  2. 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.
  3. OpenGL has a 2D projection mode where you can draw lines and polygons.
  4. 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 call 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

Here an example bitmap (which you need to convert to .tga).

Sample bitmap

相关问答

更多
  • 编辑:其实,我不再确定。 几个版本后来,似乎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 "λ> "
  • 这很可能是因为您将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 ...
  • :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 ...
  • 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 ...
  • 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"] ...

相关文章

更多

最新问答

更多
  • 在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
  • Java中的不可变类(Immutable class in Java)
  • 寻求多次出现的表达式(Seeking for more than one occurrence of an expression)
  • linux只知道文件名,不知道在哪个目录,怎么找到文件所在目录
  • Actionscript:检查字符串是否包含域或子域(Actionscript: check if string contains domain or subdomain)
  • 懒惰地初始化AutoMapper(Lazily initializing AutoMapper)
  • 使用hasclass为多个div与一个按钮问题(using hasclass for multiple divs with one button Problems)
  • Windows Phone 7:检查资源是否存在(Windows Phone 7: Check If Resource Exists)
  • EXCEL VBA 基础教程下载
  • RoR - 邮件中的动态主体(部分)(RoR - Dynamic body (part) in mailer)
  • 无法在Google Script中返回2D数组?(Can not return 2D Array in Google Script?)
  • JAVA环境变量的设置和对path , classpth ,java_home设置作用和目的?
  • mysql 关于分组查询、时间条件查询
  • 如何使用PowerShell匹配运算符(How to use the PowerShell match operator)
  • Effective C ++,第三版:重载const函数(Effective C++, Third edition: Overloading const function)
  • 如何用DELPHI动态建立MYSQL的数据库和表? 请示出源代码。谢谢!
  • 带有简单redis应用程序的Node.js抛出“未处理的错误”(Node.js with simple redis application throwing 'unhandled error')
  • 使用前端框架带来哪些好处,相对于使用jquery
  • Ruby将字符串($ 100.99)转换为float或BigDecimal(Ruby convert string ($100.99) to float or BigDecimal)
  • 高考完可以去做些什么?注意什么?
  • 如何声明放在main之后的类模板?(How do I declare a class template that is placed after the main?)
  • 如何使用XSLT基于兄弟姐妹对元素进行分组(How to group elements based on their siblings using XSLT)
  • 在wordpress中的所有页面的标志(Logo in all pages in wordpress)
  • R:使用rollapply对列组进行求和的问题(R: Problems using rollapply to sum groups of columns)
  • Allauth不会保存其他字段(Allauth will not save additional fields)
  • python中使用sys模块中sys.exit()好像不能退出?
  • 将Int拆分为3个字节并返回C语言(Splitting an Int to 3 bytes and back in C)
  • 在SD / MMC中启用DDR会导致问题吗?(Enabling DDR in SD/MMC causes problems? CMD 11 gives a response but the voltage switch wont complete)
  • sed没有按预期工作,从字符串中间删除特殊字符(sed not working as expected, removing special character from middle of string)
  • 如何将字符串转换为Elixir中的函数(how to convert a string to a function in Elixir)