BorisJu 0 Posted September 9, 2019 I'm trying to get data from an LPR camera. Data is in mixed TXT and JPG format. I am using THttpCli component with GET method in synchronous or asynchronous operation. Is it possible to read the contents of RcvdStream and then set the stream to zero (empty). I'm trying with RcvdStream.Seek (0,0) but all the past content is still in the stream on next event or next read the stream. The stream is TMemoryStream. Thanks in advance. Boris Share this post Link to post
Angus Robertson 574 Posted September 9, 2019 You empty a stream with the clear method, that resets the position to the start as well. Seek to start is when you have read or written to the stream. Beware cameras can produce a lot of data and you have to keep up with it or frames are lost. This may be one rare example where it's better to capture data in a thread particularly if you need to display it real time which can also be a struggle, or at least was 15 years ago on the hardware I was using, guess everything is a lot faster now. One streaming technique is an endless HTML page, it says page length zero in the header, then sends one MIME block per frame, up to 25 per second. You don't want to save that to a stream...or at least clear it after each frame. You may be better using the OnDocData event to receive small amounts of data rather than a stream, but also be careful about copying it between buffers, that slows everything down as well. Angus Share this post Link to post
BorisJu 0 Posted September 9, 2019 Hi Angus I don't catch the video frame, but LPR result from camera, but also have a lot of mixed data, text data and jpeg image. I try to receive data on OnDocData event, but I can't clear the RcvdStream. (HttpCli.RcvdStream as TmemoryStream).Clear; But at the next event, it still had old content and new. Boris Share this post Link to post
Angus Robertson 574 Posted September 9, 2019 So the camera does the hard work and gives you a plate number? RcvdStream is optional, set it to Nil and it is not written, and you just store what appears in the OnDocData event. Angus Share this post Link to post
BorisJu 0 Posted September 10, 2019 Yes, the camera does ha hard work. Sometimes you look at the solution but you don't see it ... I solved the problem with the event, without the stream... Thanks Angus Share this post Link to post