English 中文(简体)
通过GET申请接收JPEG图像
原标题:Receiving JPEG images via http GET request
  • 时间:2011-07-27 11:52:25
  •  标签:
  • c++

我想通过GET的请求,从一架IP照相机接收吉大港山区上空的图像。 我写了一个节目,制作与摄像机有关的短片,并向摄影机发出以下GET申请:

GET /mjpeg?res=full HTTP/1.1
Host: 143.205.116.14


After that, I receive images with the following function in a while loop:

while((tmpres = recv(sock,(void *) buf, SIZE, 0)) > 0 && check<10)

.....

where SIZE represents the size of the buffer. I, infact, don t know what size to define here. I am receiving a color image of size 2940x1920. So I define SIZE=2940x1920x3. After receiving the MJPEG image, I decode it with ffmpeg. But I observe that ffmpeg just partially/uncorrectly decodes the image and I just see a half (or even less) of the image. I assume it could be a size problem. Any help in this regard would be highly appreciated.

Regards,

Khan

最佳回答

为什么要重新发明轮轮椅(时间为十三)? 使用一个现成的吉大港山区客户图书馆,例如libcurl

为此,或许你甚至可以用<代码>curl把你的全部解决办法写成单册。 指挥线方案:

#!/bin/sh

curl -O "http://143.205.116.14/mjpeg?res=full" || echo "Error."
curl -o myfile.jpg "http://143.205.116.14/mjpeg?res=full" || echo "Error."

# ffmpeg ...
问题回答

Save bytes received as binary file and analyze. 或许是一种不完整的形象(图像可以编码为进步的JPEG,事实上是相互交织的,也就是说,如果你把档案按横向线排列的话,或者可以成为一个症状。 或者有些不同。 <代码>check < 10 conditions?





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签