2D: Faster way to roll an image?

Just starting out? Need help? Post your questions and find answers here.
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: 2D: Faster way to roll an image?

Post by dige »

Thx pf_shadoko,

I have saved your code and an original 360 degree photo under the link above ( http://u.pc.cd/mvx7 )
saved.
Unfortunately, Ogre or the technology doesn't seem to be able to handle higher resolution images.
LoadTexture(0,GetFilePart(image)) failed. Tested with PB 6.11 x64.

The image resolution is: 11.904x5.592 pixel.

My goal would be to be able to process the actual panorama images that are composed from drone photos.
These have a resolution of 20.192 x 10.096 pixels.

Kind regards

Dige
"Daddy, I'll run faster, then it is not so far..."
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: 2D: Faster way to roll an image?

Post by wilbert »

dige wrote: Wed Jul 03, 2024 8:29 am My goal would be to be able to process the actual panorama images that are composed from drone photos.
These have a resolution of 20.192 x 10.096 pixels.
The code below ignores direction for now and is hardcoded to 'down'.
The purpose is so you can test if the approach with DrawigBuffer would be of any help to you.
If it does help, up, left and right can be added as well.

Code: Select all

Procedure RollImage (ImgID, direction, offset)
  If StartDrawing(ImageOutput(ImgID))
    *db = DrawingBuffer()
    pitch = DrawingBufferPitch()
    po = pitch * offset
    *m = AllocateMemory(po, #PB_Memory_NoClear)
    CopyMemory(*db, *m, po)
    MoveMemory(*db + po, *db, pitch * (OutputHeight() - offset))
    CopyMemory(*m, *db + pitch * (OutputHeight() - offset), po)
    FreeMemory(*m)
    StopDrawing()
  EndIf
EndProcedure
Windows (x64)
Raspberry Pi OS (Arm64)
BarryG
Addict
Addict
Posts: 4130
Joined: Thu Apr 18, 2019 8:17 am

Re: 2D: Faster way to roll an image?

Post by BarryG »

@dige: Is the full path to the image being specified?
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: 2D: Faster way to roll an image?

Post by dige »

BarryG wrote: Wed Jul 03, 2024 11:08 am @dige: Is the full path to the image being specified?
Yes. It runs fine with the './Pano_360.jpg', but not with './Insta360_X4_Smaple_image.jpg'
"Daddy, I'll run faster, then it is not so far..."
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: 2D: Faster way to roll an image?

Post by dige »

wilbert wrote: Wed Jul 03, 2024 8:43 am The code below ignores direction for now and is hardcoded to 'down'.
The purpose is so you can test if the approach with DrawigBuffer would be of any help to you.
If it does help, up, left and right can be added as well.
[..]
Well done wilbert! Your code seems to be 4x times faster! Thank you very much :D
"Daddy, I'll run faster, then it is not so far..."
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: 2D: Faster way to roll an image?

Post by wilbert »

dige wrote: Wed Jul 03, 2024 1:01 pm Well done wilbert! Your code seems to be 4x times faster!
That's good to know. :)

Would all directions (horizontal, vertical, diagonal) be equally important and used for you big 20.192 x 10.096 pixel images ?
What would be the minimum and maximum offset values you intend to use ?
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
pf shadoko
Enthusiast
Enthusiast
Posts: 385
Joined: Thu Jul 09, 2015 9:07 am

Re: 2D: Faster way to roll an image?

Post by pf shadoko »

it's not a problem related to the 3d PB (ogre): in my case, your 11904 X 5952 image works fine.
it must be linked to the graphics circuit

I've modified the code to support zooming (with mousewheel)

Code: Select all

InitEngine3D():InitSprite():InitKeyboard():InitMouse()

ExamineDesktops()
OpenWindow(0, 0,0, DesktopWidth(0)*0.8,DesktopHeight(0)*0.8, "CreateShader - [Esc] quit",#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0), WindowHeight(0), 0, 0, 0)

image.s="C:\Users\Guillot\Downloads\Insta360_X4_Smaple_image.jpg"
If FileSize(image)<0:MessageRequester("!", "enter 360 panoramic image path (above)"):CallDebugger:EndIf
Add3DArchive(GetPathPart(image), #PB_3DArchive_FileSystem):Parse3DScripts()
LoadTexture(0,GetFilePart(image))

CreateCamera(0, 0, 0, 100, 100):MoveCamera(0,0,3,-6):CameraLookAt(0,0,0,0)
CreateMaterial(0,TextureID(0))
DisableMaterialLighting(0,1)
MaterialCullingMode(0,#PB_Material_AntiClockWiseCull)
MaterialFilteringMode(0,#PB_Material_Anisotropic)
CreateSphere(0,1000,64,64)
CreateEntity(0,MeshID(0),MaterialID(0))

Define.f MouseX,Mousey,fov=45

Repeat
	While WindowEvent():Wend
	ExamineKeyboard()
	ExamineMouse()
	MouseX = -MouseDeltaX() *  0.05
	MouseY = -MouseDeltaY() *  0.05
	FOV-MouseWheel()*5:If fov<10:fov=10:ElseIf fov>90:fov=90:EndIf
	CameraFOV(0,fov)
	RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)	
	RenderWorld()
	FlipBuffers()    
Until KeyboardReleased(#PB_Key_Escape) Or MouseButton(3)
User avatar
Caronte3D
Addict
Addict
Posts: 1355
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: 2D: Faster way to roll an image?

Post by Caronte3D »

Perfect! 8)
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: 2D: Faster way to roll an image?

Post by Fred »

I can confirm it works perfectly here as well with the big pic (a bit slow to start though) on a very old gfx card and it looks fantastic !
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: 2D: Faster way to roll an image?

Post by dige »

Fred wrote: Wed Jul 03, 2024 4:00 pm I can confirm it works perfectly here as well with the big pic (a bit slow to start though) on a very old gfx card and it looks fantastic !
Oh what a pity that it doesn't work here :-( I feel like I've been excluded from the party :cry:

Can you please tell me under which conditions you got the big picture for viewing?

PB version?, x64 / x86? Debugger on / off? Compiled?
Windows version?

I habe Windows 10, Intel i7-6700, NVIDIA FX 580, 24GB RAM

Tested with PB 6.11 x64/x84 - LoadTexture () allways failed :?


Update:

I have gradually reduced the size of the image by 1000 pixels.
But at a size of 8,000 x 4,000 I got this error

NVIDIA OpenGL Driver
An application has requested more GPLI memory than is available in the system.
The application will now be closed.
Error Code: 6
Would you like to visit
http://nvidia.custhelp.com/app,'answers ... Va_id/3553 for help?

With 7.000 x 3.500 it works, but that is unfortunately far from the required B-size of approx. 20,000 pixels.
Last edited by dige on Thu Jul 04, 2024 8:54 am, edited 1 time in total.
"Daddy, I'll run faster, then it is not so far..."
User avatar
Caronte3D
Addict
Addict
Posts: 1355
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: 2D: Faster way to roll an image?

Post by Caronte3D »

You must edit the following line with the path and name of your jpg file:

Code: Select all

image.s="C:\Users\Guillot\Downloads\Insta360_X4_Smaple_image.jpg"
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: 2D: Faster way to roll an image?

Post by dige »

Caronte3D wrote: Thu Jul 04, 2024 8:51 am You must edit the following line with the path and name of your jpg file:

Code: Select all

image.s="C:\Users\Guillot\Downloads\Insta360_X4_Smaple_image.jpg"
Thank you for your help.
But the path is correct, otherwise the check in line 10 would also fail:

Code: Select all

10 : If FileSize(image)<0:MessageRequester("!", "enter 360 panoramic image path (above)"):CallDebugger:EndIf
"Daddy, I'll run faster, then it is not so far..."
User avatar
HeX0R
Addict
Addict
Posts: 1189
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: 2D: Faster way to roll an image?

Post by HeX0R »

dige wrote: Thu Jul 04, 2024 8:43 am I habe Windows 10, Intel i7-6700, NVIDIA FX 580, 24GB RAM
Wow, you are using a 15 year old graphic card with just 512MB?
It might be time to invest a few € in something more up to date.
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: 2D: Faster way to roll an image?

Post by Fred »

Of course 512 MB is history for GFX cards, no wonder it doesn't work..
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: 2D: Faster way to roll an image?

Post by dige »

HeX0R wrote: Thu Jul 04, 2024 9:12 am Wow, you are using a 15 year old graphic card with just 512MB?
Yes, maybe a bit old and no longer suitable for gaming, but so far sufficient for me and I guess, still better than onboard graphics. :wink:

But I'm just wondering what Fred meant by a "very old gfx card" 🤔
Fred wrote: Wed Jul 03, 2024 4:00 pm I can confirm it works perfectly here as well with the big pic (a bit slow to start though) on a very old gfx card and it looks fantastic !
"Daddy, I'll run faster, then it is not so far..."
Post Reply