Author Topic: PCL: Compiling new module with VC9  (Read 10719 times)

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
PCL: Compiling new module with VC9
« on: 2009 August 31 19:43:21 »
Hi guys

Today I tried to compile using VC2008 express. It has been a loooong time since I compiled anything, and those times I used MingW... and PCL has changed a lot :)

Well, so here I am, asking for help :)

I modified a project file included in the last PCL to include my code, and this is the result when I hit the compile option:

Code: [Select]
------ Build started: Project: CHT, Configuration: Debug Win32 ------

Compiling...

CHTInstance.cpp

e:\pcl\include\pcl\diagnostics.h(41) : error C2448: '_Pragma' : function-style initializer appears to be a function definition

e:\pcl\include\pcl\container.h(22) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

e:\pcl\include\pcl\container.h(22) : error C2440: 'initializing' : cannot convert from 'const char [19]' to 'int'

        There is no context in which this conversion is possible

e:\pcl\include\pcl\container.h(22) : error C2143: syntax error : missing ';' before 'namespace'

e:\pcl\include\pcl\mathcore.h(202) : error C2064: term does not evaluate to a function taking 1 arguments

e:\pcl\include\pcl\mathcore.h(203) : error C2144: syntax error : 'const long double' should be preceded by ';'

e:\pcl\include\pcl\mathcore.h(205) : error C2064: term does not evaluate to a function taking 1 arguments

e:\pcl\include\pcl\mathcore.h(206) : error C2144: syntax error : 'int' should be preceded by ';'

e:\pcl\include\pcl\pixeltraits.h(48) : error C2448: '_Pragma' : function-style initializer appears to be a function definition

e:\pcl\include\pcl\pixeltraits.h(112) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

e:\pcl\include\pcl\pixeltraits.h(112) : error C2440: 'initializing' : cannot convert from 'const char [19]' to 'int'

        There is no context in which this conversion is possible

e:\pcl\include\pcl\pixeltraits.h(112) : error C2143: syntax error : missing ';' before ''template<''

e:\pcl\include\pcl\pixeltraits.h(267) : error C2065: '__FLUT8' : undeclared identifier

e:\pcl\include\pcl\pixeltraits.h(279) : error C2065: '__FLUT8' : undeclared identifier

e:\pcl\include\pcl\pixeltraits.h(291) : error C2065: '__FLUT16' : undeclared identifier

e:\pcl\include\pcl\pixeltraits.h(303) : error C2065: '__FLUT16' : undeclared identifier

e:\pcl\include\pcl\pixeltraits.h(694) : error C2065: '__DLUT8' : undeclared identifier

e:\pcl\include\pcl\pixeltraits.h(706) : error C2065: '__DLUT8' : undeclared identifier

e:\pcl\include\pcl\pixeltraits.h(718) : error C2065: '__DLUT16' : undeclared identifier

e:\pcl\include\pcl\pixeltraits.h(730) : error C2065: '__DLUT16' : undeclared identifier

e:\pcl\include\pcl\pixeltraits.h(1137) : error C2065: '__FLUT8' : undeclared identifier

e:\pcl\include\pcl\pixeltraits.h(1137) : fatal error C1903: unable to recover from previous error(s); stopping compilation

Build log was saved at "file://e:\PCL\src\modules\processes\CHT\vc9\Debug\BuildLog.htm"

CHT - 22 error(s), 0 warning(s)

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Seems like something weird in the PCL... or an outdated call that I'm making somewhere. Any hints?
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: PCL: Compiling new module with VC9
« Reply #1 on: 2009 August 31 19:46:38 »
By the way, I forgot to menction that I'm working on an implementation of the Circular Hough Transform. It is an algorithm to find circles in an image. Next will come the Linear Hough Transform, to find straight lines... Not much for practical use in astronomical images, but useful in object detection for general image processing :)
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline Nocturnal

  • PixInsight Jedi Council Member
  • *******
  • Posts: 2727
    • http://www.carpephoton.com
Re: PCL: Compiling new module with VC9
« Reply #2 on: 2009 August 31 20:35:12 »
Hi Carlos,

have you tried to compile the sample (sandbox) that comes with PCL? I remember struggling a bit to get compilation of my code to work as well but it's possible that sandbox has been updated to compile correctly by now. In particular you may need to define a Windows #define so that PCL uses the correct code sections. Ah, I just looked at the sandbox vcproj file and it's still problematic. You need to define __PCL_WINDOWS which for sandbox is only defined for Release, not for Debug. That's not correct. It should be a general project property.

Anyway, try defining __PCL_WINDOWS and see if it compiles.
Best,

    Sander
---
Edge HD 1100
QHY-8 for imaging, IMG0H mono for guiding, video cameras for occulations
ASI224, QHY5L-IIc
HyperStar3
WO-M110ED+FR-III/TRF-2008
Takahashi EM-400
PIxInsight, DeepSkyStacker, PHD, Nebulosity

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: PCL: Compiling new module with VC9
« Reply #3 on: 2009 August 31 22:29:12 »
You are right :) Compiling the Sandbox project yields the same errors.

Now I'm hitting my head on a wall trying to find where I should define that variable :D I vaguely remember doing this on my W98 laptop, messing with the autoexec.bat file, right? :D

Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: PCL: Compiling new module with VC9
« Reply #4 on: 2009 August 31 22:36:04 »
Allright, I changed the active mode to release, and now Sandbox compiles fine... now its time to debug my module :P

Thanks Sander!!!
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: PCL: Compiling new module with VC9
« Reply #5 on: 2009 September 01 00:24:00 »
It seems that I finally corrected all the errors... but now I got a linking error:

Quote
LINK: fatal error LNK1181: cannot open input file 'PCL-vb9.lib'


It sounds like he cannot find the propper folder... How/where can I solve this?
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline Nocturnal

  • PixInsight Jedi Council Member
  • *******
  • Posts: 2727
    • http://www.carpephoton.com
Re: PCL: Compiling new module with VC9
« Reply #6 on: 2009 September 01 06:18:33 »
You need to add $(PCLDIR)/lib to your library paths in VC++. That's part of your project's properties. I also recommend you make the debug mode work otherwise you can't debug your code :)
Best,

    Sander
---
Edge HD 1100
QHY-8 for imaging, IMG0H mono for guiding, video cameras for occulations
ASI224, QHY5L-IIc
HyperStar3
WO-M110ED+FR-III/TRF-2008
Takahashi EM-400
PIxInsight, DeepSkyStacker, PHD, Nebulosity

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: PCL: Compiling new module with VC9
« Reply #7 on: 2009 September 01 10:14:40 »
Ok ok :) Edited the project file with the notepad and finally found those commands :)
Now, the module is supposed to compile, link, everything... but I don't understand the output (under Win32/Release).

There is a -pxm.dll.intermediate.manifest file, 1kb and a -pxm.lib, 3kb file... kindda weird. How do I get one single .dll, the right one?
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: PCL: Compiling new module with VC9
« Reply #8 on: 2009 September 01 10:34:39 »
Hi Carlos,

Welcome back mon ami :D

Well, I see you finally have been able to compile and link your module, or that's what seems from your last post, with Sander's help (thanks Sander ;) ). Those *.manifest and *.lib files are temporary ones that you don't need at all; just ignore them.

You must define the PCLDIR environmental variable. This variable must point to the directory where you have PixInsight+PCL installed —which should be C:\PCL if you made a standard installation. Recall that this hasn't changed since the old PCL versions you used some time ago.

As Sander has pointed out, the debug project that comes with Sandbox is broken (don't hesitate to kick me, Sander). I'll try to fix all VC++ projects in the next version. However I see you have started to edit .vcproj files manually, which is kinda "advanced", so you should have no problems. Basically, the debug project lacks include and lib directories, and the required __PCL_WINDOWS preprocessor macro. With these things defined, it should work.

If you have compiled and linked your module, the project automagically copies the resulting -pxm.dll module file to your $(PCLDIR)/bin directory. Then you must install it from PI core (Process > Install Modules ...).

Keep us informed about that circular Hough transform module. Detecting circular things sounds like detecting stars, and that's good my friend  ;D
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: PCL: Compiling new module with VC9
« Reply #9 on: 2009 September 01 11:09:11 »
Same enviroment variable, but different computer :D I used my old pentium 2 laptop with W98 for early development, now I'm using a P4 - XP one for compiling and linking...
Anyway, this are the lines that are currently present on the autoexec.bat:
set PCLDIR=E:\PCL
SET PATH=E:\PCL;E:\PCL\INCLUDE
(PI has been installed on the e: partition, so it is fine).

Nothing advanced at all about using the notepad! Sometimes my old side comes to the surfice, remembering those glorious old days old DOS... :) I was unable to find the variables through the user interfase :D
I copied the preprocessor macro to the debug modes. Also modified the folder of the link directory, wich was nonexistant.

Now I found the correct .dll :) it was under a folder VC9 created... not the standard bin one (where the main application is).
The definition in the project file is:
OutputFile:"$(PCLDIR)\dist\PCL32\$(ProjectName)-pxm.dll
Another thing to fix, or this was your intention? :)


The CHT is not very good for stars... a PSF fitting should be better. The CHT founds circular objects, not spheres :) like a "O", not filled.
I'm working with some guys at the Phisics Faculty, extracting molecular shapes from their images. Now, I have to obtain the mean radius of several "molecules", wich look something like a bunch of grapes (overlaping). The next project is to detect triangles, and then measure their orientations. That is the Linear Hough Transform for.
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: PCL: Compiling new module with VC9
« Reply #10 on: 2009 September 01 12:35:28 »
All right, the bakery has return to bussines, and the furnace is hot ;)

Juan, I just send to you the source code and the win32 compilled version, along with one of the microscopic images, in case you want to give it a try/look.

I'm going to modify this code to create a "product" for PI users, and not just this thing ad-hoc for my needs :D I'll need a hand with the console outputs ;)


So, the schedule is this: first, I need to get results from the images (today-tomorrow). Then, I'll create a module for Grandient extraction, and one for a simple, yet powerfull Circular Hough Transform extraction. After that, comes the Linear one... hopefully, this won't take much more than a week (I'm in the middle of exams).


Thank you very much Sander and Juan for your help!
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: PCL: Compiling new module with VC9
« Reply #11 on: 2009 September 01 15:55:18 »
Hi Carlos,

Great! I'll take a good look at your code tomorrow. However I ask for some patience because I am in the process of updating my main workstation. This involves a series of gigantic backups, hardware updates, installation and tuning of Fedora 11, and reinstallation of all virtual machines. Add to this the new Snow Leopard (OS X 10.6), and I'll be quite a bit busy during the next days...

This is an extremely interesting work that can have many and exciting applications, including detecting stars as circles, of course! (just subtract two consecutive wavelet layers and all stars turn into O's :) ).
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: PCL: Compiling new module with VC9
« Reply #12 on: 2009 September 03 09:02:41 »
Hmmm, I'm not as excited as you about this application. For a simple detection, there are much more faster algorithms, and easier to implement, as a simple intensity peak search, gaussian fitting, etc. Even to find the size of the star the Hough transform is not well adecuate, because you try several radiuses, and see how the transform changes. If you see my implementation, I create alpha channels for each different radius. Of course, we may try a search in a three dimensional space, through the image coordinates and channels, but is very inneficient, if you just want the center and radius of a star. Another problem is that if the field is crouded, like in the microscopic image I sent to you, there is an overlap in the transformation space, so false detections are made.

Having said that, I think that I may device a much more robust system of detection of the circles in the Hough space. I'm developing in my brain's back-working-space a way to create a "circleness" variable, to discriminate between detections. Now, this may be usefull to tell if a detection was a round star or something completely else.


Another point to discuss. Even when the Hough transform is highly inneficient (in terms of the algorithm), I was surprised by the speed at it worked! Much better than what I though.


The final discussion: the radiuses avalaible. I pretended to search for real values for the radiuses, but for the sake of avoiding problems with the accumulators, and to optimice the code, I ended with a solution that only works for integer values. Do you have any good algorithm to draw a circle, with a radius defined by a float variable?


Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com