Jump to content

dadreamer

Members
  • Posts

    353
  • Joined

  • Last visited

  • Days Won

    35

Everything posted by dadreamer

  1. For this you would need to: - change the type of the user event in two locations: on the diagram and in the callback code; - slightly change the callback logic, trying some things: first try to post the cluster with the data handle address instead of the array, second try to not allocate the array and copy the data into it, but post the original SDK pointer to LV directly. Plus in fact we even don't decode the data ourselves - the PlayM4 decoder does it for us! As we need the data type mostly and don't need the actual data contents, we could ease the callback logic a little. But I neither want to say you to do this right now, nor I'm inclined to do this myself. I think Rolf is going to come with more advanced diagnostics or solutions.
  2. Actually I would try to eliminate one handle allocation by passing a pointer with PostLVUserEvent and dereferencing it in LabVIEW (+ deallocate it manually, of course) (as I already mentioned on the first pages of this thread). It would be more of a test to see if the large memory consumption goes away. If not, then it's reasonable to allocate the space just one time (when the DLL is loaded, for example, or right on the diagram with DSNewPtr) and free it when the app ends (when the DLL is unloaded or with DSDisposePtr on the diagram).
  3. Win32 Decode Img Stream.vi does not produce memory leaks of any sort. I've been running it on a production for months. Never ever received errors from that VI. As to CoInitializeEx, it was implemented this way in the original thread on SO, I just borrowed the solution. But I checked now, CoInitializeEx always returns TRUE, no matter what. Extra resources are not allocated. I assume it's safe enough to call it multiple times from the same thread. But you may easily add CoUninitialize to there, if you're afraid it works improperly. I'm just thinking this might be not a good idea, given that description of the function: A lot of work would be done on each call. Better to do this once on the app exit. Or leave it to the OS, when LabVIEW quits.
  4. You may relatively easy check this. Make a test VI and remove there everything related to the PlayM4 decoder and the image conversion. Leave the User Event completely empty. Get the memory space measurements during the run of that VI.
  5. Yeah, something is not freed properly and eating your resources. You need to find what it is.
  6. I'm afraid you need to check and test everything. By the way. Do you see a memory leak in Windows Task Manager when running the app for a long time? Compare the occupied memory space, when you've just started the stream, with that one after a hour. You mean GetJPEG returning 0? If that occurs on the recent version of your VI, then it might be that when the image is very large, it takes too much time to process the data, and your LV User Event doesn't have a chance to handle it all in time. You need to view the Event Inspector and watch the amount of events in there.
  7. Very hard to tell. You need to check the functions return values one by one, and not only in LabVIEW, but in the DLL as well. Use DbgPrintf window to ease the debugging. To me it seems more like a call sequence mistake of some sort. But it may be resource leaking too, as if for example you'd forget to close some handle or free some pointer.
  8. Better now. I would move that Stop, CloseStream and FreePort stuff to the main loop (to "stop" frame), but it's your decision.
  9. Not that normal for sure. Usually such a video translation takes about 10 to 15 percent of CPU load. I suggest to try: - increase the loop delay from 10 to 50 ms; - as you know, that your image size is constant (1280x720), eliminate the GetPictureSize CLFN completely and move the Initialize Array node outside the loop.
  10. Something like that, but... - Why all your CLFNs are orange again? - You did not introduce a minimum delay for the loop. - Better to use some button, pressing which you would capture the image. So you would need a Case Structure or an Event Structure in that second loop to handle the button actions.
  11. You should have moved only PlayM4_GetPictureSize and PlayM4_GetJPEG to a parallel loop. The other functions should remain as they are, i.e. in the callback event frame. Now as you moved everything PlayM4 related and did not introduce a minimum delay for the loop, your While loop runs with a very high frequency, not only hogging up the system resources, but also executing few unnecessary runs for one User Event! To clarify, in each callback event you need to call InputData once, but you call it one, two, three times in a row or even more!
  12. Yes, that is why it was an one-time test. Remove all that file writing stuff and add the Decode Image Stream VI instead. It will decode the stream in memory. Obviously I just deleted first 4 bytes from the file as you forgot to connect the boolean constant and the VI was adding an extra integer of the array size to the beginning of the file. Plus it's known how the JPEG header starts, so it's relatively easy to find its first bytes in almost any file.
  13. You may stick with that Decode Image Stream VI, if you prefer JPEG format. Look at the Write to Binary File VI more closely.
  14. Can you zip it? The forum tries to handle it in its own way.
  15. Just save and look at it. It's just for a one-time test anyway, so doesn't matters which moment you're capturing on your camera. You don't need that inner "2" Case Structure, remove it.
  16. I doubt there would be problems. Rolf already has set the CLFNs in his HikVision examples to any thread, so I could conclude that those functions are reenterant (thread-safe). Of course, it must be clarified with the documentation from the developer, but I accepted it on faith. 🙂 Moreover, you should move your GetJPEG call to a parallel loop as it's blocking your callback event frame, not letting it to process another events. Hence you see freezes of the GUI. Or limit the event queue in the Event Structure settings. Or use Flush Event Queue as suggested. It is. Why do you think otherwise? What's your issue? Just write the array into a binary file with a ".jpg" extension exactly one time and you're done.
  17. But if GetJPEG call is blocking, you don't have any other ways except implementing PlayM4 callback in the C code.
  18. To any thread. They should become yellow. But yes, you have a way too much events queued!
  19. Re-read my previous message. And maybe you have a large bunch of events in the queue? Check with the Event Inspector.
  20. Only those stated in the documentation. This is the minimum size required. But it may occur that this size is not enough - this needs some testing on your side. If you would use BMP, then there's a more or less precise formula, but BMPs are quite larger in size, as you know. Also I, as Rolf did few posts ago, suggest using PlayM4_GetPictureSize function to know the actual image size. Insert it between InputData and GetJPEG nodes. Are you saying that those GetJPEG/GetBMP functions are synchronous and don't return until the buffer is filled? What if you switch all the HikVision and PlayM4 CLFNs from UI thread to any thread (yellow coloring)? Then it would run in another thread and not freeze the GUI.
  21. Well, I see from your data that you're finally getting a valid JPEG stream. Can you save that pJpeg array into a binary file and open it in a viewer? Just to make sure it's the cam image. And now you need to figure out the proper array size so the GetJPEG function wouldn't error on you anymore. And in your "Stop" frame you should accomplish the cleanup procedures such as stopping the playback, freeing the port etc. Just find the opposite functions according to your UserEvent frame calls.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.