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

相关问答

更多

Haskell图形库在MacOS X上的GHCi中工作(Haskell Graphics Library that works in GHCi on MacOS X)

编辑:其实,我不再确定。 几个版本后来,似乎GLFW不再适用于OS X上的GHCi。 事实证明,GLFW + OpenGL满足所有四个要求! 你需要用ghci -framework Carbon调用ghci。 你需要EnableGUI.hs文件,你可以在这里获得。 请注意,您无法将其加载到GHCi中,您必须首先将其加密。 OpenGL有一个2D投影模式,可以绘制线条和多边形。 位图可以作为纹理加载并放在多边形上。 这是一个小例子,它将一个位图放到屏幕上。 对位图有一些限制:它的尺寸必须是2的幂(这...

ghci:Emacs haskell-mode中的自定义提示(ghci: Custom Prompt in Emacs haskell-mode)

在最新的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)

这很可能是因为您将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 th...

Haskell / GHCI中的别名(Aliases in Haskell/GHCI)

: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/Sandbo...

是否有支持内联图形显示的ghci GUI前端/扩展,如ipython?(Is there any ghci GUI frontend/extension that support inline graphics display like ipython? [closed])

有一个名为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中使用GHCI的Haskell外部函数接口(Haskell Foreign Function Interface with GHCI in Windows)

这是因为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...

Haskell,限制GHCI内存(Haskell, Limit GHCI memory)

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 n...

在GHCi中工作>但不是在加载时?(Works in GHCi> but not when loaded?)

阅读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 sta...

Haskell GHCi - 使用getContents在stdin上使用EOF字符(Haskell GHCi - Using EOF character on stdin with getContents)

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 :) ...

Haskell在`ghci`中多行`let`(Haskell multi-line `let` in `ghci`)

在GHCi中,您可以使用:{ :}表示多行表达式。 例如: Prelude> :{ Prelude| let bar = ["a", Prelude| "b", Prelude| "c"] Prelude| :} :{ :}阻止GHCi在下一个换行符之后评估你的代码并向你抛出错误,因为它不是一个完整的表达式。 另请注意,顶级定义不需要let 。 在普通的Haskell源文件中,您只需编写: bar = ["a", "b", ...

相关文章

更多

快速了解MongoDB【基本概念与体系结构】

什么是MongoDB MongoDB is a general purpose, document-b ...

Stack Overflow Architecture Update - Now At 95 Million Page Views A Month

A lot has happened since my first article on theSta ...

MongoDB的体系结构_深入浅出MongoDB(三)

MongoDB和关系数据库逻辑结构关系对比,数据存储结构,MongoDB数据类型

Hibernate架构体系结构

org.hibernate.SessionFactory接口提供了工厂方法来获取Session的对象

传说中的WeixinJSBridge和微信rest接口

直接上图,金山的APP“微信导航”,从界面上看有粉丝数等关键数据,实现了直接关注功能,莫不是rest接 ...

LVS体系结构

使用LVS架设的服务器集群系统有三个部分组成:最前端的负载均衡层,用Load Balancer表示,中 ...

MongoDB集成Hadoop进行统计计算

MongoDB 本身可以做一些简单的统计工作,包括其内置的基于 Javascript 的 MapRed ...

Solr Architecture[转]

Lucene/Solr plugins •RequestHandlers – handle a r ...

《Apache源代码全景分析-第1卷:体系结构与核心模块》扫描版[PDF]

中文名: Apache源代码全景分析-第1卷:体系结构与核心模块 作者: 张中庆 梁雪平 ...

对比下HBase, Memcached, MongoDB, Redis和Solr

转自:http://3834362.blog.51cto.com/3824362/1354092

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本