Jump to content

alvise

Members
  • Posts

    209
  • Joined

  • Last visited

Posts posted by alvise

  1. I don't quite understand what you mean here.

    Quote

    Edit: I'll be damned! A VI inserted into a Subpanel does not have a window handle at all. I thought I had tested that but somehow got apparently misled in some ways. LabVIEW seems to handle that all internally without using any Windows support for that. So back to the drawing board to make that not a Subpanel window but instead using real Windows Child window functionality. I don't like to use the main VIs front panel as the drawing canvas as the library would draw all over the front panel and fighting LabVIEWs control and indicator redraws.

     

  2. No, I don't want you to waste any more time, if you can tell me what to do, that would be enough.
    Since there is no other alternative, I have to compile the code and continue.

    Quote

    The problem with that code I showed you is that even if you can compile it and it works as expected, the real trouble for you will only just have started. The data you will receive in that callback event is NOT any standard image data, it is not even decoded. That means you will still have to decode the H264 or some other compressed data packages that you will receive. And honestly that would be even for me quite a task to solve. 

    maybe I can find the conversion dll for the SDK itself. So I have to deal with it somehow.

     

      HMODULE hDLL = LoadLibraryW(L"HCNetSDK.dll");
        if (hDLL)
        {
            Type_SetStandardDataCallBack installFunc = (Type_SetStandardDataCallBack)GetProcAddress(hDLL, "NET_DVR_SetStandardDataCallBack");
            if (installFunc)

    Since "HANDLE" is written here (7 argument of type "HANDLE" is incompatible with parameter of type "HMODULE" hikvision-labview
      there was a problem. I changed it to HMODULE, a bug was resolved.

     

     

    typedef BOOL(__stdcall* Type_SetStandardDataCallBack)(LONG lRealHandle,fStdDataCallBack cbStdDataCallBack, DWORD dwUser);
    
    LibAPI(BOOL) InstallStandardCallback(LONG lRealHandle, LVUserEventRef* refnum)

     

    ,
    Error (active)    E0020    identifier "fStdDataCallBack" is undefined    hikvision-labview callback - x86-Debug    D:\HIKVISION\hikvision-labview callback\hikvision-labview callback.cpp    46 

    I'm getting this error but what I don't understand is that there are no tokens here  

    image.png.489fa76fc0b269c2b0ac5180147e9713.png

    hikvision-labview callback.cpp

  3. 26 minutes ago, dadreamer said:

    Add SuperSecretPrivateSpecialStuff=True line into your LabVIEW.ini and you will find it. 😉

    Ok I tried that and saw labview but my attempt to see video stream fails again. That's not the problem here.

     

    2 hours ago, Rolf Kalbermatter said:

    3) There is an error in on the Start vi. but you of course obscured that part of the VI, so we can't say if that is the reason. lUserID being 0 looks slightly suspicious but of course it could be a valid value since the documentation for the NET_DVR_Login_V30() function states that this is 0 or higher on success, and -1 indicates an error.

    Looking at the SDK user manual I read the same thing. This shouldn't be a problem.

  4. I'm not talking about the complexity of the code you wrote, there are too many details, I'm just talking about the confusion in my head while trying to wrap up the general situation. This situation gets a little confusing. Your code is pretty clean :)

    image.png.da2c9ac062ea859d651e80be3adacabd.png

    I'm running the start.vi code directly as you shared and I'm actively using the 32-bit domain.

    Also I am using LV2018.I cannot find FP.NativeWindow in VI property node.I'm getting the thought that this might be the problem.

  5. Thanks for your comprehensive explanations.

    Quote

     

    No! My example tries to replicate your posted Preview code. In there is only the exception callback which is used for error reporting to the user application and which I dutifully ignored to make the example more simple. Instead I did try to implement proper error handling by using the return value of each API call and requesting the last error information if that return value indicates an error. This should be more than enough for simple example code, most example code out there simply ignores any and all errors, which I find a very bad practise as when something doesn't work you have no idea where it starts to fail.

    The SDK documentation seems to indicate that this exception callback is optional so it should not affect the operation of the sample.

     

     

    First of all, I would like to go over the sample code you shared, if we are sure that this code will not work, I would like to move on to dll compilation in the next step.
    When I tested the code you shared, I recaptured the wire values with the images below. And I took the photos as below. Something is not right here. Do you think there is a problem?

    image.png.43261157ff937533a738bf8b72e69dc1.png

    image.png.c568870099acb118cbc54ce5ab47deea.png

    If you say skip this example, I will skip this example. I will move on to the next steps you wrote.

  6. Do I understand correctly what you are saying? I still need to create a .dll in C++ to use the labview code you shared here.

    I need to compile the code below (after adapting the part added as C# code to C/C++ language) and create the .dll file, right?

    Quote

     

    #include <stdio.h>
    #include <iostream>
    #include <time.h>
    #include "Windows.h"
    #include "extcode.h"

    using namespace std;

    LVUserEventRef *pUE;

    void SendEvent(LVUserEventRef *rwer)
    {
      pUE = rwer;
    }

    void CALLBACK g_DataCallBack(LONG lRealHandle, DWORD dwDataType, BYTE *pBuffer, DWORD dwBufSize, void *pUser)
    {
     

                    byte[] sData = new byte[dwBufSize];
                    Marshal.Copy(pBuffer, sData, 0, (Int32)dwBufSize);

                    string str = "test.ps";
                    FileStream fs = new FileStream(str, FileMode.Create);
        Here is the example created in C#. But I have to convert it to C/C++ code.
                    int iLen = (int)dwBufSize;
                    fs.Write(sData, 0, iLen);
                    fs.Close();  

      PostLVUserEvent(*pUE, (void *)&pBuffer); is here as well
    }

     

    If this step is correct I think I need to make some plugin in the labview code you shared that should get this callback.Live video output can be seen after adding the callback plugin as well.

     

    There is probably nothing as difficult as putting the pieces together in this confusion.

    -Not:I don't have a chance to use 64-bit labVİEW, currently I can only use 32-bit.

     

  7. When the new calback function worked the correct HCNetSDK location, it created a connection and read the camera's information. Now the connect and Start button works, the labview does not crash, there is only a small problem, there is no image.
    -What could be the reason for this?

    image.png.0fe55017c290f267905aacb8b80e408d.png

    The description here mentions the callback event. That shouldn't be a problem, right?

    Did you choose NET_DVR_RealPlay specifically because it has this function NET_DVR_RealPlay_V30

  8. Thanks for your answers.

    On Shaunr's suggestion, I focused on C#. I think I misunderstood the issue. But it's not bad, I gained a little more experience.

    I leave aside the issue of communicating with labview using C#.
    The piece of code I have created with labview so far has been created using only the HCNETSDK.dll file and this dll file has been created using C++. There is also the HCNETSDK.h file.

    At the point of What can I do now, I've come to this wing, correct me if I'm wrong.
    - I need to write a piece of code in C++ and in this code I need to communicate with the labview by importing the extcode.h header file and using the PostLVUserEvent function. I will do this just to understand the communication between the dll I created and the labview.
    Doesn't this example here already do that?

    -In C++ code, I will import the header file HCNETSDK.h and extcode.h, then call the PostLVUserEvent function and adapt the callback from labview with this function to the following snippet and finally I will compile this code and create a dll file.

     //Set exception callback function
     NET_DVR_SetExceptionCallBack_V30(0, NULL,g_ExceptionCallBack, NULL);
     //---------------------------------------
     //Start preview and set to callback stream data
     LONG lRealPlayHandle;
     HWND hWnd = GetConsoleWindow(); //Get window handle
     NET_DVR_CLIENTINFO ClientInfo = {0};
     ClientInfo.hPlayWnd = hWnd; 
     //If need to decode, please set it valid. If want to get stream data only, it can be set to NULL
     ClientInfo.lChannel = 1; // Preview channel NO.
     ClientInfo.lLinkMode = 0; /* The high bit (31) 0 means the main stream, while 1 means the sub 
    stream. Bit 0~bit 30 are used for link mode: 0- TCP mode, 1- UDP mode, 2- Multi-play mode, 3- RTP mode, 4- RTP 
    over RTSP, 5- RTSP over HTTP */

    Below is the C++ sample code I can use.

     

    I have taken into account your suggestion to run the Labview code in the while loop.

    C++ live stream.cpp

  9. Quote

    Almost certainly not a PostScript file. That PS probably stands for something the developer ate that day or maybe it could be his initials or the initials of his girl friend. We likely will never know. 😀

    Something that comes up just when trying to guess is "PostScript".
     then I will add different letters there. OK? :)

    Saves a photo with the attached code to the location where the labview code is located. Currently the code is bound to the event indexed button so it takes a picture and the program is stopped, when it is stopped it is recording a picture.

    Should I go to the marathon right now? :)
    I also want to pass, but I don't know exactly how. To use the PostLVUserEvent function, the extcode.h header file must be added to the C# code, but that is a separate event for how to do it in C#.

    hikvision 7.0.1.vi

  10. -I understand the situation a little more. JPEG can only be used for snapshots.
    -I can compile the sample application now. We can make changes to the interface or other functions.

    Now I have taken the next step.

    Quote

     

    Next. That example saves a file in the callback (实时流数据.ps). You may have to change the filename to an ascii one for LabVIEW to read it as LabVIEW doesn't support Unicode. You should be able to read that file from LabVIEW (after is is closed). That is the raw data that you would normally get back from a callback. Read that file in LabVIEW and figure out how to interpret it (it's a byte array [array of u8]. The callback is

    public void RealDataCallBack(Int32 lRealHandle, UInt32 dwDataType, IntPtr pBuffer, UInt32 dwBufSize, IntPtr pUser)

    This callback (for a .NET Assembly or a similar one for C[++]) would be where you put the PostLVUserEvent instead of saving to a file. Your problem at that point is telling the callback to use a LabVIEW refnum.  Don't worry about putting that in for now, we can talk about that later.

     

    Quote

     

            public void RealDataCallBack(Int32 lRealHandle, UInt32 dwDataType, IntPtr pBuffer, UInt32 dwBufSize, IntPtr pUser)
            {
                if (dwBufSize > 0)
                {
                    byte[] sData = new byte[dwBufSize];
                    Marshal.Copy(pBuffer, sData, 0, (Int32)dwBufSize);

                    string str = "实时流数据.ps";
                    FileStream fs = new FileStream(str, FileMode.Create);
                    int iLen = (int)dwBufSize;
                    fs.Write(sData, 0, iLen);
                    fs.Close();            
                }
            }

     

    I think this is "实时流数据.ps." It's a PS (PostScript) extension, isn't it? I will change the name.

    I'm trying to understand the situation by looking at the example here. But how can I adapt this to the code I'm using?

  11. thanks for the answer. What I really needed was to go step by step. I will inform you after I have followed each step.

    Quote

    You have a working example (Preview.cs). Do you know how to compile it? If not, that's your first task-get an executable out of the example code. This will be your golden standard for checking your program is doing things right.

    I tested the application created as preview.exe, everything works correctly.I can compile preview.js. I am currently trying to compile it.

    Quote

    There are also other functions that you can call directly from LabVIEW that don't require a callback (e.g. NET_DVR_CaptureJPEGPicture & NET_DVR_CapturePicture) and take normal parameters that you can pass directly. Get those working from LabVIEW (more progress

    I can see the function names you mentioned here in HCNetSDK.dll.
    So you're talking about the possibility of using them directly to receive video streams?

     

    but I will go through everything step by step and give you feedback.

  12. Thanks everyone for the replies.
    Right now, I'm pretty confused. I've looked through all the searches on Google, but I've been looking blankly as there are a lot of things I can't understand at the moment.

    Some reasons why I am confused:
    -First of all, I'm trying to prepare a dll file with C++, but how can I create it? For example: Here is the code

     

    Quote
    typedef void(CALLBACK *REALDATACALLBACK)(
      LONG      lRealHandle,
      DWORD     dwDataType,
      BYTE      *pBuffer,
      DWORD     dwBufSize,
      void      *pUser
    );

    How am I going to use the code here as an output function.

    -second case, I'm looking at the examples here.Is ''iCube Camera in'' here a wrapper dll file? what?

    -third case: How is the "Reg Event Callback" mentioned by ShaunR used in my case and what is the problem in its use?

    -fourth case: dadreamer , what do you mean by labview may bite you in addition to not fully understanding how to use the event you mentioned?

    -finally: I know there are many ways to reach that stage, but I'm asking to get the whole thing in my head.How do I use the video screen output? Is the .Net function used or how?

    It would really help if someone could tell me how to proceed step by step because I can understand it with practice. Everything is abstract for me right now.

    Thank you for any ideas given.


     

     

     

     

  13. good answer :)
    This camera's SDK is shared, but I have insufficient knowledge of C++ or C# when trying to generate the required code. After a long hiatus from using the C++ language, even looking at the visual studio code editor, I feel like I was forgotten on mars. This indicates that I need to work again to create the required dll file.
    Although at first it seemed like something I could only do with labview, now I'm starting to understand the depth of it.
    With dadreamer help, we can read the information from the camera with the labview, but there is a problem in the video stream part.

    I'm reviewing the code here. I am researching and reading useful information.
    https://forums.ni.com/t5/Sample-Code/Post-Events-to-a-LabVIEW-Event-Structure-From-a-Dll/ta-p/3996283

     

  14. Looking at the C# example, I'm trying to gather the labview code and understand how to use the callback event, and I added the renewed code (I don't know if I'm progressing correctly). There are some things I still don't understand.
    In the C# example, "pUser" and

            public void RealDataCallBack(Int32 lRealHandle, UInt32 dwDataType, IntPtr pBuffer, UInt32 dwBufSize, IntPtr pUser)
    		{
                if (dwBufSize > 0)
                {
                    byte[] sData = new byte[dwBufSize];
                    Marshal.Copy(pBuffer, sData, 0, (Int32)dwBufSize);
    
                    string str = "ʵʱ������.ps";
                    FileStream fs = new FileStream(str, FileMode.Create);
                    int iLen = (int)dwBufSize;
                    fs.Write(sData, 0, iLen);
                    fs.Close();            
                }
    
    

    IntPtr pUser    also in this line. 

    m_lRealHandle = CHCNetSDK.NET_DVR_RealPlay_V40(m_lUserID, ref lpPreviewInfo, null/*RealData*/, pUser)

     

    Extra: What I want to create now is just a screen that shows the video and the PTZ control. Is it possible that this is that hard in Labview?

     

    Am I the only crazy one who wants to control these cameras with labview why no examples :)

    hikvision 7.1.vi

  15. Thanks for your help.

    -With this camera, it does not appear as a direct usb com port with NI-IMAQdx. Because it needs to encode MPEG4 or H.264 video, but labview only supports MPJEG.
    -Video can be streamed over VLC RTSP, but the video is delayed.

    The C# code I want to create is as attached. It contains the PTZ control.
    I guess I need to search for the wrapper DLL.

    While examining the C# example(Preview.cs), I saw that ''HCNetSDK.NET_DVR_RealPlay_V40 '' is used for video streaming. I guess this does not change the situation.

    Preview.cs PreSet.cs

×
×
  • Create New...

Important Information

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