Jump to content

Cyclothymia

Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Everything posted by Cyclothymia

  1. UPDATE: SOLVED I realized that this was due to a typecasting problem: MATLAB on its own has smart casting during function calls. When running the script in LABVIEW, which is strictly typed, the solution was to explicitly cast imread into double(): bar = double(imread("foo.jpg"));
  2. UPDATE [6th August 2008]: I have yet to solve the problem, or even gotten any idea of how to solve it. I tried rewriting the code with Visual C++ (instead of Dev-CPP) and then running the DLL through LabVIEW using the Visual Studio "attach to process" debugging method; it ran through without any complications for multiple times. Again, this generated DLL: 1) Works fine for any amount of times with a new VI with a Call Lib Func node is written for the DLL 2) Stops working once LabVIEW.exe is closed, reopened, and the VI is run again. 3) will work again if the code is copy-and-pasted into a new blank VI without changing any properties; as long as LabVIEW.exe is not closed and reopened, it will still work. 4) This cycle of errors is repeatable and no different from the one generated by the Dev-CPP compiler. I would very, very much appreciate any new input to this problem, even some indication that LabVIEW has a bug or something, or erroneous IDE settings, or a comment on my n00bishness... ANYTHING at all.
  3. QUOTE (gleichman @ Jul 30 2008, 01:25 PM) Yes, I think so. The VI runs perfectly fine if I merely copy and paste the block diagram into a new VI and save it without modification.
  4. This is my first time making a DLL and programming in C++, so please bear with me if I had made some fundamental mistakes. I have made a DLL that reads images and performs Canny edge detection using the OpenCV libraries. So I made a very simple LabVIEW program to test it --> [see attached image] It worked fine, as long as the file was still open, so I saved and quit. HOWEVER, when I restarted LabVIEW again and ran the same program, it stopped working and generated error 1097: ---- Error 1097 occurred in Call Library Function Node in Canny.dll: An exception occurred within the external code called by the Call Library Function Node. The exception may have corrupted LabVIEW's memory. Save any work to a new location and restart LabVIEW. ---- The only way I got it to work again was to copy and paste the program contents into a new file, save and run. It worked once again, as long as the file was open. I also made a C++ program that calls the DLL, and it works fine, regardless of when it was called. I have a feeling that it might have to do with memory allocation, but I'm not sure. Any help would be appreciated. ps. I am not permitted to upload .cpp, .dev, or .dll files for some reason. #include "getpathdll.h"#include // C++ includes#include //#include // already included in getpathdll.h// OpenCV includes#include #include //#include //#include #define LoThresh 160#define HiThresh 160#define ApertureSize 3 // 1,3,5,7extern "C"{DLLIMPORT int cvApplyCanny(); BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ , DWORD reason /* Reason this function is being called. */ , LPVOID reserved /* Not used. */ ) { return TRUE; } DLLIMPORT int cvApplyCanny () { //Initialize error log? also line 93 char* LoadImagePath = fnGetPath("original", "01-11089.jpg"); IplImage* iniImage = cvLoadImage(LoadImagePath); //Create a temporary and final image IplImage* grayImage = cvCreateImage(cvSize(iniImage->width, iniImage->height), IPL_DEPTH_8U, 1); IplImage* edgeImage = cvCreateImage(cvSize(iniImage->width, iniImage->height), IPL_DEPTH_8U, 1); //Convert image to grayscale cvCvtColor(iniImage, grayImage, CV_BGR2GRAY); //Perform Canny edge detection cCanny(grayImage, edgeImage, LoThresh, HiThresh, ApertureSize); char* SaveImagePath = fnGetPath("canny", "YayWorked.jpg"); cvSaveImage(SaveImagePath, edgeImage); // Destroy the images cvReleaseImage(&iniImage); cvReleaseImage(&grayImage); cvReleaseImage(&edgeImage); } #undef DLLIMPORT
  5. I have been struggling to get imread to work in MATLAB scripts. I have gotten the exact same lines of code to work both in the MATLAB Command Window from LabVIEW, and in MATLAB as well. I believe my variables (only one to output the resultant image array) have been named correctly. I have considered using Mathscript also (imread works in Mathscript with some modification to data types), but if imread works, I will need to call the GRAB function which uses cell arrays. Although I could have modified the code to avoid using cell arrays it would be a last resort. When running the vi I get the following error: ======================================================================== Error 1048 occurred at LabVIEW: LabVIEW failed to get variable from the script server. Server:"7.4.0.287 (R2007a) " in MATLABscripts.vi Possible reason(s): LabVIEW: LabVIEW failed to get variable from the script server. ======================================================================== I have looked up on knowledgebase information on the NI website, and also [HERE], to no avail. The version of LabVIEW I am using is 8.5, and for MATLAB 2007a. Any help would be appreciated.
×
×
  • Create New...

Important Information

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